Esempio n. 1
0
        public async Task GetAllLocations_ShouldBeDoneSuccessfully()
        {
            // Arrange
            var locations = new List <Location>()
            {
                new Location()
                {
                    Id        = 1,
                    Name      = "Test",
                    Country   = new Country(),
                    City      = new City(),
                    CityId    = 1,
                    CountryId = 1,
                    Groups    = new List <Group>()
                }
            };

            var locationsToReturn = new List <LocationToReturnDto>()
            {
                new LocationToReturnDto()
                {
                    Id      = 1,
                    City    = "Test",
                    Country = "Test",
                    Name    = "Test"
                }
            };

            _unitOfWorkMock.Setup(x => x.Locations.GetAllLocationsWithInclude())
            .ReturnsAsync(locations);

            _mapperMock.Setup(x => x.Map <ICollection <LocationToReturnDto> >(locations))
            .Returns(locationsToReturn);

            // Act
            var result = await _sut.GetAllLocations();

            // Assert
            Assert.Equal(locations.FirstOrDefault().Id, result.FirstOrDefault().Id);
        }