Esempio n. 1
0
        public void EnumParserTestShouldRetunNull()
        {
            var options       = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString());
            var carRepository = new EfDeletableEntityRepository <Car>(new ApplicationDbContext(options.Options));

            var service = new AdService(carRepository);

            Assert.Throws <NullReferenceException>(() => service.EnumParser("Lada", "1"));
            Assert.Throws <IndexOutOfRangeException>(() => service.EnumParser("Audi", "100"));
        }
Esempio n. 2
0
        public void EnumParserTestsShouldReturnStringModel()
        {
            var options       = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString());
            var carRepository = new EfDeletableEntityRepository <Car>(new ApplicationDbContext(options.Options));

            var service = new AdService(carRepository);

            // should return - 80
            var audi = service.EnumParser("Audi", "1");

            // should return - 640
            var bmw = service.EnumParser("Bmw", "40");

            // should return - Marea
            var fiat = service.EnumParser("Fiat", "12");

            // should return - iMiEV
            var mitsubishi = service.EnumParser("Mitsubishi", "10");

            Assert.Equal("80", audi);
            Assert.Equal("640", bmw);
            Assert.Equal("Marea", fiat);
            Assert.Equal("iMiEV", mitsubishi);
        }