public void add_resource()
        {
            //Arrange
            const string TITLE = "title";
            const string CONTENT = "content";
            const string AUTHOR = "author";
            const string SUBMITUSER = "******";
            const string REFERENCEURL = "http://a.b.com";
            _session.SetupStoreExpectation<Resource>(r => r.Title == TITLE && r.Content == CONTENT && r.Author == AUTHOR && r.SubmitUser == SUBMITUSER);

            var source = new Resource
            {
                Title = TITLE,
                Content = CONTENT,
                Author = AUTHOR,
                SubmitUser = SUBMITUSER,
                Tags = new List<Resource.ResourceTag>(),
                ReferenceUrl = REFERENCEURL
            };

            //Act
            var resource = _resourceRepositorySUT.Add(source);

            //Assert
            _session.VerifyAll();
            Assert.Equal(TITLE, resource.Title);
            Assert.Equal(CONTENT, resource.Content);
            Assert.Equal(AUTHOR, resource.Author);
            Assert.Equal(SUBMITUSER, resource.SubmitUser);
        }
Esempio n. 2
0
 public void UpdateResource(string id, Resource resource)
 {
     var resourceUpdate = _repository.GetResourceById(id);
     resourceUpdate.Title = resource.Title;
     resourceUpdate.Content = resource.Content;
     resourceUpdate.LastUpdateTime = DateTime.Now;
     resourceUpdate.Author = resource.Author;
     resourceUpdate.SubmitUser = resource.SubmitUser;
     resourceUpdate.ReferenceUrl = resource.ReferenceUrl;
     resourceUpdate.Tags = resource.Tags;
     _repository.Save();
 }
Esempio n. 3
0
        public void Can_add_resource()
        {
            var source = new Resource();
            //Arrange
            _repository.Setup(r => r.Add(source)).Returns(_resource).Verifiable();
            _repository.Setup(r => r.Save()).Verifiable();

            //Act
            var resource = _service.AddResource(source);

            //Assert
            _repository.VerifyAll();
            Assert.Equal(_resource, resource);
        }
Esempio n. 4
0
        public Resource Add(Resource source)
        {
            var resource = new Resource
                               {
                                   Title = source.Title,
                                   Content = source.Content,
                                   Author = source.Author,
                                   CreateTime = DateTime.Now,
                                   LastUpdateTime = DateTime.Now,
                                   SubmitUser = source.SubmitUser,
                                   Tags = source.Tags,
                                   ReferenceUrl = source.ReferenceUrl
                               };

            _documentSession.Store(resource);
            return resource;
        }
Esempio n. 5
0
 public Resource Add(Resource resource)
 {
     _documentSession.Store(resource);
     return resource;
 }
Esempio n. 6
0
 private void ProcessResourceTag(Table table, Resource resource)
 {
     foreach (var row in table.Rows)
     {
         if (row["Field"] == "Tags")
         {
             resource.Tags = row["Value"].ToTagList();
         }
     }
 }
Esempio n. 7
0
 private void AssertResource(Resource resource, ResourceDetailViewModel resourceDetailViewModel)
 {
     Assert.Equal(resource.Title, resourceDetailViewModel.Title);
     Assert.Equal(resource.Content, resourceDetailViewModel.Content);
     Assert.Equal(resource.Author, resourceDetailViewModel.Author);
     Assert.Equal(resource.ReferenceUrl, resourceDetailViewModel.ReferenceUrl);
     Assert.Equal(resource.Tags.Count, resourceDetailViewModel.Tags.ToTagList().Count);
 }
Esempio n. 8
0
 private void AssertUnchangedFields(Resource resource, ResourceViewModel resourceViewModel)
 {
     Assert.Equal(resource.Author, resourceViewModel.Author);
     Assert.Equal(resource.SubmitUser, resourceViewModel.SubmitUser);
 }
Esempio n. 9
0
 public Resource AddResource(Resource source)
 {
     var resource = _repository.Add(source);
     _repository.Save();
     return resource;
 }
Esempio n. 10
0
        public void Can_update_resource()
        {
            //Arrange
            var resourceToUpdate = new Resource() { Title = "Title to update", Content = "Content to update" };
            _repository.Setup(r => r.GetResourceById(ID)).Returns(_resource);
            _repository.Setup(r => r.Save()).Verifiable();

            //Act
            _service.UpdateResource(ID, resourceToUpdate);

            //Assert
            _repository.VerifyAll();
            ResourceShouldBeUpdated(_resource, resourceToUpdate);
        }
Esempio n. 11
0
 private void ResourceShouldBeUpdated(Resource resource, Resource resourceToUpdate)
 {
     Assert.Equal(resourceToUpdate.Title, resource.Title);
     Assert.Equal(resourceToUpdate.Content, resource.Content);
     Assert.Equal(_prepareTime, resource.CreateTime);
     Assert.True(resource.LastUpdateTime > _prepareTime);
 }