public async void Deletes_Operation_Successfully() { //Arrange var user = Context.Users.First(); var operation = Context.Operations.First(); OperationsRepository.Setup(x => x.Delete(It.IsAny <DateTime>(), user.Id)).ReturnsAsync(true).Verifiable(); //Act var result = await OperationsRepository.Object.Delete(operation.Date, user.Id); //Assert result.Should() .BeTrue(); OperationsRepository.Verify(); DbContextFactory.Destroy(Context); }
public async void Starts_Sale_Process() { //Arrange var contact = new Contact { Id = Guid.Empty, Name = "Contact", Type = "Client", Company = "Contact co.", PhoneNumber = "000", Email = "Contact@", Notes = "ABC", Status = "Inactive", Source = "Social Media" }; var user = new User { Id = "1U", UserName = "******", DisplayName = "TestUser ", Email = "@test", Level = "mid" }; UserAccessor.Setup(x => x.GetLoggedUser()).ReturnsAsync(user).Verifiable(); OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), user)).ReturnsAsync(true).Verifiable(); Mediator.Setup(x => x.Send(It.IsAny <StartSaleProcessCommand>(), new CancellationToken())) .ReturnsAsync(Unit.Value); //Act var addContactCommand = new StartSaleProcessCommand(contact); var handler = new StartSaleProcessCommandHandler(Context, UserAccessor.Object, OperationsRepository.Object); var result = await handler.Handle(addContactCommand, new CancellationToken()); //Assert result.Should() .BeOfType <Unit>() .Equals(Unit.Value); UserAccessor.Verify(); OperationsRepository.Verify(); DbContextFactory.Destroy(Context); }
public async void Adds_New_Operation_Successfully() { //Arrange var user = Context.Users.First(); var operation = new Operation { Opportunity = true, Date = DateTime.Now, }; OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), user)).ReturnsAsync(true).Verifiable(); //Act var result = await OperationsRepository.Object.Add(operation, user); //Assert result.Should() .BeTrue(); OperationsRepository.Verify(); DbContextFactory.Destroy(Context); }
public async void Deletes_Order_Successfully() { //Arrange var order = Context.Orders.First(); OperationsRepository.Setup(x => x.Delete(It.IsAny<DateTime>(), order.UserId)).ReturnsAsync(true).Verifiable(); Mediator.Setup(x => x.Send(It.IsAny<DeleteOrderCommand>(), new CancellationToken())) .ReturnsAsync(Unit.Value); //Act var deleteOrderCommand = new DeleteOrderCommand(order.Client, order); var handler = new DeleteOrderCommandHandler(Context, OperationsRepository.Object); var result = await handler.Handle(deleteOrderCommand, new CancellationToken()); //Assert result.Should() .BeOfType<Unit>() .Equals(Unit.Value); OperationsRepository.Verify(); DbContextFactory.Destroy(Context); }
public async void Adds_New_Order_Successfully() { //Arrange var contact = Context.Contacts.First(); var user = Context.Users.First(); UserAccessor.Setup(x => x.GetLoggedUser()).ReturnsAsync(user); OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), user)).ReturnsAsync(true).Verifiable(); Mediator.Setup(x => x.Send(It.IsAny <AddOrderCommand>(), new CancellationToken())) .ReturnsAsync(Unit.Value); //Act var addOrderCommand = new AddOrderCommand(contact, true, "test", 10, 100, ""); var handler = new AddOrderCommandHandler(Context, UserAccessor.Object, OperationsRepository.Object); var result = await handler.Handle(addOrderCommand, new CancellationToken()); //Assert result.Should() .BeOfType <Unit>() .Equals(Unit.Value); DbContextFactory.Destroy(Context); }
public async void Closes_Order_Successfully() { //Arrange var order = Context.Orders.First(); var user = Context.Users.FirstOrDefault(x => x.Id == order.UserId); UserAccessor.Setup(x => x.GetLoggedUser()).ReturnsAsync(user).Verifiable(); OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), It.IsAny <User>())).ReturnsAsync(true).Verifiable(); Mediator.Setup(x => x.Send(It.IsAny <CloseOrderCommand>(), new CancellationToken())) .ReturnsAsync(Unit.Value); //Act var closeOrderCommand = new CloseOrderCommand(order); var handler = new CloseOrderCommandHandler(Context, UserAccessor.Object, OperationsRepository.Object); var result = await handler.Handle(closeOrderCommand, new CancellationToken()); //Assert result.Should() .BeOfType <Unit>() .Equals(Unit.Value); OperationsRepository.Verify(); DbContextFactory.Destroy(Context); }