public void InventoryController_TakeOutByLabel_ReturnsInventoryItem_WhenAddedInventoryExists(int addYears) { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now.AddYears(addYears); var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; // Act _inventoryController.Add(inventoryItem); var result = _inventoryController.TakeOutByLabel(itemLabel); // Assert Assert.That(result.Label, Is.EqualTo(itemLabel)); }
public void InventoryService_NoNotificationSending_WhenItemDoesNotExist() { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now.AddYears(+1); var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; //_inventoryRepository.GetByLabel(Arg.Any<string>()).Returns(inventoryItem); // Act _inventoryService.TakeOutByLabel(itemLabel); // Assert _notificationService.DidNotReceiveWithAnyArgs().Send(Arg.Any<Notification>()); }
public void InventoryService_NotificationSent_WhenItemIsNotExpiredAndTakenOut() { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now.AddYears(+1); var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; _inventoryRepository.GetByLabel(Arg.Any<string>()).Returns(inventoryItem); // Act _inventoryService.TakeOutByLabel(itemLabel); // Assert _notificationService.Received(1).Send(Arg.Is<Notification>(x => x.Code == NotificationCode.ItemHasBeenTakenOut)); }
public void InventoryRepository_SavedItemContainsLabelAndExpirationDate() { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now; var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; // Act _inventoryRepository.Save(inventoryItem); var inventoryItembyLabel = _inventoryRepository.GetByLabel(itemLabel); // Assert Assert.That(inventoryItembyLabel.Label, Is.EqualTo(itemLabel)); Assert.That(inventoryItembyLabel.ExpirationDate, Is.EqualTo(expirationDate)); }
public void InventoryRepository_DeletesItem() { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now; var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; // Act _inventoryRepository.Save(inventoryItem); _inventoryRepository.Delete(inventoryItem); var inventoryItembyLabel = _inventoryRepository.GetByLabel(itemLabel); // Assert Assert.That(inventoryItembyLabel, Is.Null); }
public void InventoryController_TakeOutByLabel_ReturnsNothing_WhenAddedInventoryWasTakenBefore() { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now; var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; // Act _inventoryController.Add(inventoryItem); _inventoryController.TakeOutByLabel(itemLabel); var result = _inventoryController.TakeOutByLabel(itemLabel); // Assert Assert.That(result, Is.Null); }
public void InventoryService_ItemIsDeletedAfterTakingIt() { // Arrange var itemLabel = "Newest inventory " + Guid.NewGuid(); var expirationDate = DateTime.Now; var inventoryItem = new Inventory { Label = itemLabel, ExpirationDate = expirationDate }; _inventoryRepository.GetByLabel(Arg.Any<string>()).Returns(inventoryItem); // Act _inventoryService.TakeOutByLabel(itemLabel); // Assert _inventoryRepository.Received(1).GetByLabel(Arg.Is(itemLabel)); _inventoryRepository.Received(1).Delete(Arg.Any<Inventory>()); }
public void Save(Inventory item) { _inventoryRepository.Save(item); }
public HttpResponseMessage Add(Inventory item) { _inventoryService.Save(item); return Request.CreateResponse(HttpStatusCode.OK); }
public void Save(Inventory item) { InventoryItemList.Add(item); }
public void Delete(Inventory item) { InventoryItemList.Remove(item); }