public void ChangeStateWidhSameState() { //Setup var proStock = list.ElementAt(6); var proStockManager = new ProductStockManager(dataServiceMock.Object); //Act //Asserts Assert.ThrowsException <Exception>( () => proStockManager.ChangeStateProductStock( proStock, 3, StateEnum.Available)); }
public void ChangeStateWidhLongerAmount() { //Setup var proStock = list.ElementAt(6); var proStockManager = new ProductStockManager(dataServiceMock.Object); //Act //Asserts Assert.ThrowsException <Exception>( () => proStockManager.ChangeStateProductStock( proStock, 8, StateEnum.AwaitingForPaid)); }
public void ChangeToNextStateProductStockExist() { //Setup var productStock = list.ElementAt(0); var proStockManager = new ProductStockManager(dataServiceMock.Object); //Act var productStockNewState = proStockManager.ChangeStateProductStock( productStock, 2, StateEnum.AwaitingForPaid); //Asserts dataServiceMock.Verify(m => m.Update <ProductStock>(It.IsAny <ProductStock>()), Times.Exactly(2)); Assert.IsNotNull(productStockNewState); Assert.AreEqual(2, productStockNewState.ProductStockId); Assert.AreEqual(7, productStockNewState.Amount); Assert.AreEqual(StateEnum.AwaitingForPaid, productStockNewState.State); Assert.AreEqual(8, productStock.Amount); }
public void ChangeToNextStateProductStockNotExist() { //Setup var productStock = list.ElementAt(2); dataServiceMock.Setup(m => m.Insert(It.IsAny <ProductStock>())) .Returns(new ProductStock() { ProductStockId = 8, ProductId = 3, ProviderId = 1, Amount = 2, State = StateEnum.AwaitingForPaid, Code = "31" + StateEnum.AwaitingForPaid.ToString() }) .Verifiable(); var proStockManager = new ProductStockManager(dataServiceMock.Object); //Act var productStockNewState = proStockManager.ChangeStateProductStock( productStock, 2, StateEnum.AwaitingForPaid); //Asserts dataServiceMock.Verify(m => m.Update <ProductStock>(It.IsAny <ProductStock>()), Times.Exactly(1)); dataServiceMock.Verify(); Assert.IsNotNull(productStockNewState); Assert.AreEqual(8, productStockNewState.ProductStockId); Assert.AreEqual(2, productStockNewState.Amount); Assert.AreEqual(StateEnum.AwaitingForPaid, productStockNewState.State); Assert.AreEqual(3, productStock.Amount); }