Beispiel #1
0
        public ClientApiTest(IntegrationTestFixture <StartupApiTests> integrationTestFixture)
        {
            _integrationTestFixture = integrationTestFixture;
            var stateApiTest = new CityApiTest(_integrationTestFixture);

            Task.Run(() => stateApiTest.AddCityAsync(20)).Wait();
        }
Beispiel #2
0
        private async Task <List <ProviderViewModel> > GenerateProviders(int qty,
                                                                         int qtyAddress,
                                                                         int qtyContact,
                                                                         bool isValidAddress = true,
                                                                         bool isValidContact = true)
        {
            var cityApiTest = new CityApiTest(_integrationTestFixture);
            await cityApiTest.AddCityAsync(20);

            var cities = await cityApiTest.GetCitiesAsync();

            var providerFixture = new ProviderTestFixture();
            var providers       = providerFixture.GenerateValidProviderViewModel(qty,
                                                                                 cities,
                                                                                 qtyAddress,
                                                                                 qtyContact,
                                                                                 isValidAddress,
                                                                                 isValidContact);

            return(providers);
        }
Beispiel #3
0
        public async Task Add_AddNewClientWithIvalidAddress_ShouldNotAddAndReturnNotifications()
        {
            //Arrange
            var cityApiTest     = new CityApiTest(_integrationTestFixture);
            var citiesViewModel = await cityApiTest.GetCitiesAsync();

            var clientFixture    = new ClientTestFixture();
            var clientsViewModel = clientFixture.GenerateClientViewModel(qtyClients: 1,
                                                                         citiesViewModel: citiesViewModel,
                                                                         qtyAddress: 1,
                                                                         isValidAddress: false);

            //and act
            var postResponse = await _integrationTestFixture.Client.PostAsJsonAsync(_requestAdd, clientsViewModel.FirstOrDefault());

            //Assert
            var jsonResponse = await postResponse.Content.ReadAsStringAsync();

            var clientDeserialized = JsonConvert.DeserializeObject <Deserialize <ClientViewModel> >(jsonResponse);

            Assert.False(clientDeserialized.Success);
            Assert.Contains(ConstantMessages.StreetRequiredt_PT, clientDeserialized.Errors);
            Assert.Contains(ConstantMessages.DistrictRequired_PT, clientDeserialized.Errors);
        }