public void ShouldInsertOneItem() { var item = new ContentItem { Name = "TV", Value = 200, Category = "Electronics" }; Setup(); _mockOptions.Setup(s => s.Value).Returns(_settings); _mockClient.Setup(c => c.GetDatabase(_mockOptions.Object.Value.DatabaseName, null)).Returns(_mockDb.Object); var context = new MongoDbContext(_mockOptions.Object); var dao = new ContentItemDao(_settings); dao.Insert(item); var newItem = dao.Retrieve(item.Id); Assert.AreEqual(item, newItem); //GetAppConfig(); //var dao = new ContentItemDao(configuration.GetSection("DbSettings") as DbSettings); //dao.Insert(item); //var newItem = dao.Retrieve(item.Id); //dao.Delete(item.Id); //Assert.AreEqual(item, newItem); }
public void ChangeValueItemsShouldntBeEqual() { var item = new ContentItem { Name = "TV", Value = 200, Category = "Electronics" }; Setup(); _mockOptions.Setup(s => s.Value).Returns(_settings); _mockClient.Setup(c => c.GetDatabase(_mockOptions.Object.Value.DatabaseName, null)).Returns(_mockDb.Object); var context = new MongoDbContext(_mockOptions.Object); var dao = new ContentItemDao(_settings); dao.Insert(item); var newItem = dao.Retrieve(item.Id); dao.Delete(item.Id); newItem.Value = 300; Assert.AreNotEqual(item, newItem); }
public void ContentItemDao_Update_Exception_IntegrationTest() { using (var scope = new TransactionScope()) { // Arrange IContentItemDao target = new ContentItemDao(); // Act target.Update(new ContentItem()); } }
public void ContentItemDao_Find_IntegrationTest() { // Arrange IContentItemDao target = new ContentItemDao(); // Act ContentItem result = target.Find(18, 1); // Assert Assert.IsNotNull(result); Assert.AreEqual(7, result.Children.Count()); Assert.AreEqual(0, result.Children[0].Children.Count()); Assert.AreEqual(0, result.Children[1].Children.Count()); }
public void ContentItemDao_Add_IntegrationTest() { using (var scope = new TransactionScope()) { // Arrange IContentItemDao target = new ContentItemDao(); // Act ContentItem result = target.Add(new ContentItem() { BeginDate = 1900, EndDate = 2000, Title = "Test", ParentId = 1 }); // Assert Assert.IsTrue(result.Id != 0); } }
public void ShouldRemoveOneItem() { var item = new ContentItem { Name = "TV", Value = 200, Category = "Electronics" }; Setup(); _mockOptions.Setup(s => s.Value).Returns(_settings); _mockClient.Setup(c => c.GetDatabase(_mockOptions.Object.Value.DatabaseName, null)).Returns(_mockDb.Object); var context = new MongoDbContext(_mockOptions.Object); var dao = new ContentItemDao(_settings); dao.Insert(item); dao.Delete(item.Id); var newItem = dao.Retrieve(item.Id); Assert.IsNull(newItem); }