public void NullSender_Ctor_Throws() { IItemRepository repo = new MockItemRepository(); IFooProcessor processor = new StubFooProcessor(); IFooSender sender = null; var factory = new FooWorkflowFactory(repo, processor, sender); }
public void PostPurchase_InvalidItemNameReturnsError() { var repo = new MockItemRepository(); var controller = new PurchaseController(repo); var itemName = "NotAnItem"; var result = controller.Post(itemName); Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult)); }
public void Create_ReturnsWorkflow() { IItemRepository repo = new MockItemRepository(); IRecordDeleter deleter = new MockRecordDeleter(); var factory = new BarWorkflowFactory(repo, deleter); BarWorkflow workflow = factory.Create(); Assert.IsNotNull(workflow); }
public void GetItems_ReturnsCorrectNumber() { var repo = new MockItemRepository(); var controller = new ItemsController(repo); var data = controller.Get() as OkNegotiatedContentResult <List <IItem> >; Assert.IsNotNull(data); Assert.IsNotNull(data.Content); Assert.IsTrue(data.Content.Count == 4); }
public void Create_ReturnsWorkflow() { IItemRepository repo = new MockItemRepository(); IFooProcessor processor = new StubFooProcessor(); IFooSender sender = new MockFooSender(); var factory = new FooWorkflowFactory(repo, processor, sender); FooWorkflow workflow = factory.Create(); Assert.IsNotNull(workflow); }
public void PostPurchase_DecrementsInventory() { var repo = new MockItemRepository(); var startingCount = repo.GetInventory().Count; var controller = new PurchaseController(repo); var itemName = "TunaMelt"; var item = controller.Post(itemName) as CreatedAtRouteNegotiatedContentResult <IItem>; var newCount = repo.GetInventory().Count; Assert.IsTrue(startingCount == (newCount + 1)); }
public void PostPurchase_ReturnsSame() { var repo = new MockItemRepository(); var controller = new PurchaseController(repo); var itemName = "TunaMelt"; var item = controller.Post(itemName) as CreatedAtRouteNegotiatedContentResult <IItem>; Assert.IsNotNull(item); Assert.AreEqual(item.RouteName, "GetItemByName"); Assert.AreEqual(item.RouteValues["itemName"], item.Content.Name); Assert.AreEqual(item.Content.Name, itemName); }
public void AllValid_Run_Success() { //I don't know what a proper set of unit tests would be for a given workflow, other than that it should exercise all code paths //and confirm that all specifications are met. This is just an example. var repo = new MockItemRepository(); var deleter = new MockRecordDeleter(); var workflow = new BarWorkflow(repo, deleter); workflow.Run(); Assert.AreEqual(1, repo.TimesRun); Assert.AreEqual(2, deleter.GetDeletedBars().Count()); }
public void GetItems_WorksWithEmptyInventory() { var repo = new MockItemRepository(); repo.Clear(); var controller = new ItemsController(repo); var data = controller.Get() as OkNegotiatedContentResult <List <IItem> >; Assert.IsNotNull(data); Assert.IsNotNull(data.Content); Assert.IsTrue(data.Content.Count == 0); }
public void PostPurchase_ReturnsPopulatedItem() { var repo = new MockItemRepository(); var controller = new PurchaseController(repo); var itemName = "TunaMelt"; var response = controller.Post(itemName) as CreatedAtRouteNegotiatedContentResult <IItem>; Assert.IsNotNull(response); var newItem = response.Content; Assert.AreEqual(newItem.Name, itemName); Assert.AreEqual(newItem.Description, "Tuna melt on rye"); Assert.AreEqual(newItem.Price, 5); }
public void GetItems_ReturnsExpectedProducts() { var repo = new MockItemRepository(); var controller = new ItemsController(repo); var data = controller.Get() as OkNegotiatedContentResult <List <IItem> >; Assert.IsNotNull(data); Assert.IsNotNull(data.Content); var items = data.Content; Assert.IsTrue(items.Exists(i => i.Name == "ChickenSoup")); Assert.IsTrue(items.Exists(i => i.Name == "Caeser")); Assert.IsTrue(items.Exists(i => i.Name == "TunaMelt")); Assert.IsTrue(items.Exists(i => i.Name == "SweetFries")); }
public void GetItems_ReturnsPopulatedProduct() { var repo = new MockItemRepository(); var controller = new ItemsController(repo); var data = controller.Get() as OkNegotiatedContentResult <List <IItem> >; Assert.IsNotNull(data); Assert.IsNotNull(data.Content); var items = data.Content; var soup = items.Find(i => i.Name == "ChickenSoup"); Assert.IsNotNull(soup); Assert.IsNotNull(soup.Description); Assert.IsNotNull(soup.Price); }
public void NullDeleter_Ctor_Throws() { IItemRepository repo = new MockItemRepository(); IRecordDeleter deleter = null; var workflow = new BarWorkflow(repo, deleter); }
public void NullDeleter_Ctor_Throws() { IItemRepository repo = new MockItemRepository(); IRecordDeleter deleter = null; var factory = new BarWorkflowFactory(repo, deleter); }