예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Coverage"/> class. 
 /// </summary>
 /// <param name="coverageType">
 /// The coverage type
 /// </param>
 /// <param name="limit">
 /// The Coverage Limit
 /// </param>
 /// <param name="deductible">
 /// The Coverage Deductible
 /// </param>
 /// <param name="vehicleId">
 /// The vehicle Id.
 /// </param>
 public Coverage(CoverageType coverageType, Limit limit, Deductible deductible, int vehicleId)
 {
     this.CoverageType = coverageType;
     this.Limit = limit;
     this.Deductible = deductible;
     this.VehicleId = vehicleId;
 }
        public void TestGetDeductibleDdQueryOperation()
        {
            var deduct1 = new Deductible()
            {
                ProductId = "ABC00001", Level = 1, Amount = 2000
            };
            var deduct2 = new Deductible()
            {
                ProductId = "ABC00001", Level = 2, Amount = 3000
            };
            var conn    = new SqliteConnection("DataSource=:memory:");
            var options = new DbContextOptionsBuilder <BenefitDbContext>().UseSqlite(conn).Options;

            try
            {
                conn.Open();

                // Arrange
                using (var context = new BenefitDbContext(options))
                {
                    // Create the schema and exit to force it to create immediately
                    context.Database.EnsureCreated();
                }

                // Action
                using (var context = new BenefitDbContext(options))
                {
                    // Add records to Deductible table for assertion
                    context.Deductibles.Add(deduct1);
                    context.Deductibles.Add(deduct2);
                    var writeCount = context.SaveChanges();
                }

                // Action & Asserion
                using (var context = new BenefitDbContext(options))
                {
                    var benefitDb = new BenefitRepository(context);
                    var deduct    = benefitDb.GetDeductible("ABC00001");
                    deduct.FirstOrDefault <Deductible>().ProductId.Should().Be("ABC00001");
                }
            }
            catch (Exception e)
            {
                e.Message.Should().BeEmpty();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
                conn.Dispose();
            }
        }
        public void TestDatabaseWriteOperation()
        {
            var deduct1 = new Deductible()
            {
                ProductId = "ABC00002", Level = 1, Amount = 1000
            };
            var deduct2 = new Deductible()
            {
                ProductId = "ABC00002", Level = 2, Amount = 2000
            };
            var conn = new SqliteConnection("DataSource=:memory:");

            conn.Open();
            var options = new DbContextOptionsBuilder <BenefitDbContext>().UseSqlite(conn).Options;

            try
            {
                // Arrange
                using (var context = new BenefitDbContext(options))
                {
                    // Create the schema and exit to force it to create immediately
                    var isCreated = context.Database.EnsureCreated();
                    isCreated.Should().BeTrue();
                }

                // Action
                using (var context = new BenefitDbContext(options))
                {
                    // Add records to Deductible table for assertion
                    context.Deductibles.Add(deduct1);
                    context.Deductibles.Add(deduct2);
                    var writeCount = context.SaveChanges();
                    writeCount.Should().Be(2);
                }
            }
            catch (Exception e)
            {
                e.Message.Should().BeEmpty();
                //e.Message.Should().NotBeEmpty();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
                conn.Dispose();
            }
        }
예제 #4
0
 public static void ApplyAccumulator(Deductible accumulator)
 {
 }
 public void DecisionTest(bool deductibleMet, TypeOfVisit typeOfVisit, int reimburse)
 {
     Assert.That(Deductible.CalculateReimburse(deductibleMet, typeOfVisit), Is.EqualTo(reimburse));
 }