Exemplo n.º 1
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            ITicketService service = testServer.Host.Services.GetService(typeof(ITicketService)) as ITicketService;
            var            model   = new ApiTicketServerRequestModel();

            model.SetProperties("B", 1);
            CreateResponse <ApiTicketServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.TicketDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiTicketServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiTicketServerModelMapper();
            var model  = new ApiTicketServerRequestModel();

            model.SetProperties("A", 1);
            ApiTicketServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.PublicId.Should().Be("A");
            response.TicketStatusId.Should().Be(1);
        }
Exemplo n.º 3
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <ITicketService, ITicketRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Ticket>(null));
            var service = new TicketService(mock.LoggerMock.Object,
                                            mock.MediatorMock.Object,
                                            mock.RepositoryMock.Object,
                                            mock.ModelValidatorMockFactory.TicketModelValidatorMock.Object,
                                            mock.DALMapperMockFactory.DALTicketMapperMock,
                                            mock.DALMapperMockFactory.DALSaleTicketsMapperMock);

            ApiTicketServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }