Beispiel #1
0
        public async Task GetDogReturnsDogsUsingValidId()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <DogsDbContext>().UseInMemoryDatabase(nameof(GetDogReturnsDogsUsingValidId))
                          .Options;
            var dbContext = new DogsDbContext(options);

            CreateDogs(dbContext);

            var dogProfile    = new DogProfile();
            var configuration = new MapperConfiguration(config => config.AddProfile(dogProfile));
            var mapper        = new Mapper(configuration);

            var  sut   = new DogsProvider(dbContext, null, mapper);
            Guid dogId = Guid.Parse("005c68b6-a5e9-4fff-b7d9-c88ca27c39f1");

            // Act
            var dog = await sut.GetDogAsync(dogId);

            // Assert
            Assert.True(dog.IsSuccess);
            Assert.NotNull(dog.Dog);
            Assert.True(dog.Dog.Id == dogId);
            Assert.Null(dog.ErrorMessage);
        }
Beispiel #2
0
        public async Task GetDogsReturnsAllDogsAsync()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <DogsDbContext>().UseInMemoryDatabase(nameof(GetDogsReturnsAllDogsAsync))
                          .Options;
            var dbContext = new DogsDbContext(options);

            CreateDogs(dbContext);

            var dogProfile    = new DogProfile();
            var configuration = new MapperConfiguration(config => config.AddProfile(dogProfile));
            var mapper        = new Mapper(configuration);

            var sut = new DogsProvider(dbContext, null, mapper);

            // Act
            var result = await sut.GetDogsAsync();

            // Assert
            Assert.True(result.IsSuccess);
            Assert.True(result.Dogs.Any());
            Assert.Null(result.ErrorMessage);
        }