Esempio n. 1
0
        public void GetBrand_ById()
        {
            //ARRANGE
            var options = new DbContextOptionsBuilder <FleetManagmentContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var context = new FleetManagmentContext(options);

            IInsuranceRepository insuranceRepository = new InsuranceRepository(context);
            InsuranceTO          insurance           = new InsuranceTO
            {
                Name = "AG",
            };

            InsuranceTO insurance2 = new InsuranceTO
            {
                Name = "Ethias",
            };

            //ACT
            var addedinsurance  = insuranceRepository.Insert(insurance);
            var addedinsurance2 = insuranceRepository.Insert(insurance2);

            context.SaveChanges();

            //ASSERT
            Assert.IsNotNull(addedinsurance);
            Assert.AreNotEqual(0, addedinsurance.Id);
            Assert.AreEqual("AG", addedinsurance.Name);
            Assert.AreEqual(1, insuranceRepository.GetByID(1).Id);
        }