Example #1
0
        public async Task AddAsyncShouldAddAnimalToDb()
        {
            var db = DbInfrastructure.GetDatabase();

            var animalService = new AnimalService(db);

            const string Name   = "random name";
            const int    Age    = 5;
            const string Url    = "https://news.nationalgeographic.com/content/dam/news/2018/05/17/you-can-train-your-cat/02-cat-training-NationalGeographic_1484324.jpg";
            const string UserId = "Some user ID";

            await animalService.AddAsync(Name, Age, Url, AnimalClass.Mammal, UserId);

            var animal = await db.Animals.FirstOrDefaultAsync(a => a.Name == Name);

            animal.AnimalClass.Should().Be(AnimalClass.Mammal);

            animal.Age.Should().Be(Age);

            animal.ImageUrl.Should().Be(Url);

            animal.UserId.Should().Be(UserId);
        }