コード例 #1
0
        public async Task GetAll_Cats_Successful()
        {
            var cats = await CatService.GetAll();

            cats.Count().Should().BeGreaterThan(0);
            ApiClientMock.VerifyGetAll <Cat>();
        }
コード例 #2
0
        public async Task GetById_ForCatId_Successful()
        {
            var cat         = TestData.Cats.FirstOrDefault();
            var existingCat = await CatService.GetById(cat.Id);

            existingCat.Name.Should().Be(cat.Name);
            ApiClientMock.VerifyGetById <Cat>();
        }
コード例 #3
0
        // ReSharper disable once InconsistentNaming
        public void Token_Returns_null_if_not_Authenticated()
        {
            var client = new ApiClientMock();
            var parser = new ParserMock();

            var auth = new AuthenticationClient(client, parser);

            Assert.Null(auth.Token);
        }
コード例 #4
0
 public void Init()
 {
     unitOfWork = new UnitOfWorkMock();
     apiClient  = new ApiClientMock();
     cache      = new CacheMock();
     controller = new OrderApiController(unitOfWork, new MailHelper(new MimeMailerMock(), new RegistryReaderMock()), apiClient,
                                         new JwtDecoderMock(), cache);
     controller.Request = new HttpRequestMessage();
 }
コード例 #5
0
        public async Task DeveListarAsMarcas()
        {
            //Arrage
            var pesquisa = new ApiClientMock().Buscar();

            //Action
            var resultado = await pesquisa.ListarMarcas();

            //Assert
            Assert.NotNull(resultado);
        }
コード例 #6
0
        // ReSharper disable once InconsistentNaming
        public void Token_Passes_The_Token_To_The_API_Client(string token)
        {
            var client = new ApiClientMock();
            var parser = new ParserMock();

            var auth = new AuthenticationClient(client, parser)
            {
                Token = token
            };

            Assert.Equal($"Bearer {token}", client.DefaultRequestHeaders["Authorization"]);
        }
コード例 #7
0
        // ReSharper disable once InconsistentNaming
        public void Token_Gets_The_Token_From_The_API_Client(string token)
        {
            var client = new ApiClientMock();

            client.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

            var parser = new ParserMock();

            var auth = new AuthenticationClient(client, parser);

            Assert.Equal(token, auth.Token);
        }
コード例 #8
0
 public void Init()
 {
     unitOfWork         = new UnitOfWorkMock();
     mailHelper         = new MailHelperMock();
     pdfManager         = new PdfManagerMock();
     jwtDecoder         = new JwtDecoderMock();
     apiClient          = new ApiClientMock();
     request            = new HttpRequestMessage();
     webClient          = new WebClientMock();
     cache              = new CacheMock();
     controller         = new InvoiceHistoryApiController(unitOfWork, mailHelper, apiClient, pdfManager, webClient, jwtDecoder, cache);
     controller.Request = new HttpRequestMessage();
 }
コード例 #9
0
        // ReSharper disable once InconsistentNaming
        public void Token_Passes_The_Token_To_The_API_Client(string token)
        {
            var client = new ApiClientMock();
            var parser = new ParserMock();

            var auth = new AuthenticationClient(client, parser)
            {
                Token = token
            };

            Assert.Equal(token, client.HttpClient.DefaultRequestHeaders.Authorization.Parameter);
            Assert.Equal("Bearer", client.HttpClient.DefaultRequestHeaders.Authorization.Scheme);
        }
コード例 #10
0
        // ReSharper disable once InconsistentNaming
        public void Token_Gets_The_Token_From_The_API_Client(string token)
        {
            var client = new ApiClientMock
            {
                DefaultRequestHeaders =
                {
                    ["Authorization"] = $"Bearer {token}"
                }
            };

            var parser = new ParserMock();

            var auth = new AuthenticationClient(client, parser);

            Assert.Equal(token, auth.Token);
        }
コード例 #11
0
        public void OneTimeSetUp()
        {
            Setup.Bootstrap(SetupType.Test);

            ApiClientMock              = new ApiClientMock();
            CatServiceMock             = new CatServiceMock();
            MessageBrokerMock          = new MessageBrokerMock <Cat>();
            MessageConsumerMock        = new MessageConsumerMock <Cat>();
            MessageConsumerServiceMock = new MessageServiceMock <Cat>();
            LoggerFactoryMock          = new LoggerFactoryMock();

            CatService      = new CatService(MessageBrokerMock.Instance, ApiClientMock.Instance);
            MessageConsumer = new MessageConsumer <Cat>(ApiClientMock.Instance, LoggerFactoryMock.Instance);
            MessageService  = new MessageService <Cat>(MessageBrokerMock.Instance, MessageConsumerMock.Instance, LoggerFactoryMock.Instance);
            ViewModel       = new MainViewModel(CatServiceMock.Instance);
        }
コード例 #12
0
        public async Task Api_Client_Should_Give_Correct_Responses(string cityName)
        {
            // Arrange
            var client = new ApiClientMock();

            // Act & Assert
            if (cityName.Equals(TestDataValues.CORRECT_CITY_NAME))
            {
                var response = await client.GetOpenWeatherData(cityName);

                Assert.NotNull(response);
            }
            else
            {
                await Assert.ThrowsAnyAsync <Exception>(async() => await client.GetOpenWeatherData(cityName));
            }
        }
コード例 #13
0
        public void Init()
        {
            unitOfWork = new UnitOfWorkMock();
            apiClient  = new ApiClientMock();

            controller = new HolidayApiController(unitOfWork, new MailHelper(new MimeMailerMock(), new RegistryReaderMock()),
                                                  apiClient, new JwtDecoderMock(), new CacheMock());
            controller.Request       = new HttpRequestMessage();
            unitOfWork.Data          = Utils.CreateAdminAndUser();
            unitOfWork.Data.Holidays = new List <Holiday>
            {
                new Holiday {
                    id = 1, date = DateTime.Today, name = "holiday1"
                },
                new Holiday {
                    id = 2, date = DateTime.Today.AddDays(2), name = "holiday2"
                },
                new Holiday {
                    id = 3, date = DateTime.Today.AddYears(-1), name = "holiday3"
                }
            };
        }
コード例 #14
0
        public void Consume_DeleteMessage_Successful()
        {
            Consume_Message(MessageCommand.Delete);

            ApiClientMock.VerifyDelete();
        }
コード例 #15
0
        public void Consume_UpdateMessage_Successful()
        {
            Consume_Message(MessageCommand.Update);

            ApiClientMock.VerifyUpdate();
        }
コード例 #16
0
 public void Init()
 {
     apiClient = new ApiClientMock();
 }