public void Add() { using (var ScenGenContext = new ScenarioGeneratorModel("UnitTestUser", Connection)) { ScenGenContext.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); var record = new RiskFactorDimension(); var item = new RiskFactorDimensionDetail(); record.RiskFactorDimensionDetails.Add(item); item.Name = "XXX"; var dimType = new RiskFactorDimType(); dimType.Name = "XXX"; item.RiskFactorDimType = dimType; ScenGenContext.RiskFactorDimensionDetails.Add(item); ScenGenContext.SaveChanges(); var result = ScenGenContext.RiskFactorDimensions.Include("RiskFactorDimType").Include("RiskFactorDimensionDetail").Where(x => x.RiskFactorDimensionDetail.Name == "XXX").ToList(); Assert.AreEqual(1, result.Count()); Assert.IsNotNull(result[0].RiskFactorDimensionDetail); Assert.IsNotNull(result[0].RiskFactorDimensionDetail.RiskFactorDimType); } }
public void Add() { using (var ScenGenContext = new ScenarioGeneratorModel(UserName, Connection)) { ScenGenContext.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); var item = new RiskFactorDimType(); item.Name = "RiskFactorDimTypeXXX"; ScenGenContext.RiskFactorDimTypes.Add(item); ScenGenContext.SaveChanges(); Assert.AreEqual(ScenGenContext.RiskFactorDimTypes.Where(x => x.Name == "RiskFactorDimTypeXXX").Count(),1); } }
internal static void AddDimTypes(ScenarioGeneratorModel context) { DateTime now = context.AsOfDate; var item = new RiskFactorDimType() { Name = "Tenor", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Rating", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Seniority", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Sector", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Currency", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "IR Index", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "IL Index", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "CDS Index", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Ticker", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Country", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); item = new RiskFactorDimType() { Name = "Region", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = true }; context.RiskFactorDimTypes.Add(item); context.SaveChanges(); }