Exemplo n.º 1
0
        private IPersonalVehicleRepository BuildRepository(HttpResponseMessage httpResponseMessage, HttpMethod httpMethod, string absoluteUri)
        {
            var logger = ServiceProvider.GetService <ILogger <PersonalVehicleRepository> >();
            var httpClientFactoryMock = BuildHttpClientFactory(httpResponseMessage, httpMethod, "Fake", absoluteUri);

            TokenProviderMock.Setup(x => x.Token).Returns("loveDotNet");

            return(new PersonalVehicleRepository(Configuration, logger, httpClientFactoryMock.Object, TokenProviderMock.Object));
        }
Exemplo n.º 2
0
        public async Task GivenValidCredentialsUserShouldBeLogged()
        {
            using (var context = new CinemaDbContextFactory().CreateContext())
            {
                SetUp(context);
                var email    = User.Email;
                var password = User.Password;

                await UserService.LoginAsync(email, password);

                TokenProviderMock.Verify(m => m.CreateToken(It.IsAny <int>(), User.Role), Times.Once());
            }
        }
Exemplo n.º 3
0
        public async Task ContactRepositoryFindAllAsync_ReturnData()
        {
            // Arrange
            var responseDto         = Fixture.Create <ContactResultModel>();
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(responseDto.ToJson())
            };

            Configuration.UseOAuth = true;
            TokenProviderMock.Setup(x => x.Token).Returns("loveDotNet");
            var repository = BuildRepository(httpResponseMessage, HttpMethod.Get, $"{Configuration.BaseUrl}/contacts/v1/lists/all/contacts/all");

            // Act
            var output = await repository.FindAllAsync();

            // Assert
            output.Should().NotBeNull();
        }