public void OrderNew_Creates_A_Copy_Of_Provided_Source() { var copy = OrderUpdate.From(Source); Assert.True(copy != Source); Assert.Equal(copy.RowVersion, Source.RowVersion); Assert.Equal(copy.HouseNumber, Source.HouseNumber); Assert.Equal(copy.PostCode, Source.PostCode); Assert.Equal(copy.Price, Source.Price); Assert.Equal(copy.CustomerName, Source.CustomerName); }
public void OrderNew_Creates_A_Copy_Of_Provided_Source_And_Can_Supply_A_Callback_To_Perform_Extra_Actions_On_Copy() { var updatedName = "Updated"; var copy = OrderUpdate.From(Source, order => order.CustomerName = updatedName); Assert.True(copy != Source); Assert.Equal(copy.RowVersion, Source.RowVersion); Assert.Equal(copy.HouseNumber, Source.HouseNumber); Assert.Equal(copy.PostCode, Source.PostCode); Assert.Equal(copy.Price, Source.Price); Assert.NotEqual(copy.CustomerName, Source.CustomerName); Assert.True(copy.CustomerName == updatedName); }
public async Task Update_Method_Calls_Update_Method_Of_IOrdersRepository_In_Order_To_Execute_A_Call() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderId = OrderId.FromString(order.OrderId); var orderUpdate = OrderUpdate.From(order); await Service.Update(orderId, orderUpdate); this.Repository.Verify(repository => repository.Update(orderId, orderUpdate), Times.Once); this.Repository.VerifyNoOtherCalls(); }
public async Task Update_Method_Throws_If_Order_With_Specified_OrderId_Does_Not_Exist() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderId = OrderId.FromString(order.OrderId); var orderUpdate = OrderUpdate.From(order); using (var scope = this._repoScopeCreate()) { var ex = await Assert.ThrowsAsync <OrderDoesNotExistException>(() => scope.Repository.Update(orderId, orderUpdate)); Assert.True(ex.OrderId == orderId.Value); } }
public override IEnumerable <object[]> GetData(MethodInfo testMethod) { var validOrder = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(validOrder); var orders = new[] { new [] { OrderUpdate.From(validOrder, order => { order.CustomerName = new String('A', OrderConstants.CustomerName.MinLength - 1); }) }, new [] { OrderUpdate.From(validOrder, order => { order.CustomerName = new String('A', OrderConstants.CustomerName.MaxLength + 1); }) }, new [] { OrderUpdate.From(validOrder, order => { order.PostCode = "24124124"; }) }, new [] { OrderUpdate.From(validOrder, order => { order.HouseNumber = 0; }) }, new [] { OrderUpdate.From(validOrder, order => { order.Price = 0m; }) }, new [] { OrderUpdate.From(validOrder, order => { order.RowVersion = new byte[] { }; }) }, new IOrderUpdate[] { new OrderUpdate() }, }; return(orders); }
public async Task Update_Method_Updates_Specified_Order_And_Returns_Updated_Order() { var order = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(order); var orderNew = OrderNew.From(order); var orderId = OrderId.FromString(orderNew.OrderId); using (var scope = this._repoScopeCreate()) { await scope.Repository.Create(orderNew); } using (var scope = this._repoScopeCreate()) { var orderUpdate = OrderUpdate.From(order, update => update.CustomerName = "New Top Customer"); var updated = await scope.Repository.Update(orderId, orderUpdate); Assert.NotNull(updated); Assert.True(updated.OrderId == orderId.Value); Assert.True(updated.CustomerName == orderUpdate.CustomerName); } }