Пример #1
0
        public async Task CheckIfPartExists()
        {
            //Arrange
            var dbOptions = new DbContextOptionsBuilder <HyperCarsDbContext>()
                            .UseInMemoryDatabase("HyperCarsDb")
                            .Options;

            var db = new HyperCarsDbContext(dbOptions);

            var partService = new PartService(db);

            var part = new Part
            {
                Id   = 1,
                Name = "Test1"
            };

            db.AddRange(part);

            await db.SaveChangesAsync();

            //Act
            var result = partService.Exists(1);

            //Assert
            result.Equals(true);
        }