public void GetGroup_GroupFromDB1_GroupWithAttributeWithoutSourceClass() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1" }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2" }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity <Group>(group1); db1Adapter.AddEntity <Group>(group2); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration <Mock.DB1_Context.Group, Mock.DomainModel.GroupWitoutSourceClass>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities <Mock.DomainModel.GroupWitoutSourceClass>().FirstOrDefault(); }
public void GetGroupByID_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1" }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2" }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity <Group>(group1); db1Adapter.AddEntity <Group>(group2); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration <Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities <Mock.DomainModel.Group>().FirstOrDefault(g => g.ID == group1.Id); Assert.IsNotNull(result, "Event not found"); Assert.AreEqual(group1.Id, result.ID, "Wrong group"); }
public void GetGroupsSelectNewEntity_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1", Number = 1 }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2", Number = 1 }; var group3 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group3", Number = 2 }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity <Group>(group1); db1Adapter.AddEntity <Group>(group2); db1Adapter.AddEntity <Group>(group3); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration <Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name) .AddMap(s => s.Number, d => d.Number); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities <Mock.DomainModel.Group>() .Select(g => new { g.ID, g.Number }) .ToList(); Assert.IsTrue(result.Any(r => r.ID == group1.Id), "group1 is not found"); Assert.IsTrue(result.Any(r => r.ID == group2.Id), "group2 is not found"); Assert.IsTrue(result.Any(r => r.ID == group3.Id), "group3 is not found"); }
public void GetGroupsByNumberAndIdDoubleWhere_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1", Number = 1 }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2", Number = 1 }; var group3 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group3", Number = 2 }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity <Group>(group1); db1Adapter.AddEntity <Group>(group2); db1Adapter.AddEntity <Group>(group3); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration <Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name) .AddMap(s => s.Number, d => d.Number); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities <Mock.DomainModel.Group>() .Where(g => g.Number == group1.Number) .Where(g => g.ID == group1.Id) .First(); Assert.AreEqual(group1.Id, result.ID, "Wrong groups count"); }
public void GetGroupsWhereNumberEqual1_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1", Number = 1 }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2", Number = 1 }; var group3 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group3", Number = 2 }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity <Group>(group1); db1Adapter.AddEntity <Group>(group2); db1Adapter.AddEntity <Group>(group3); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration <Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name) .AddMap(s => s.Number, d => d.Number); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities <Mock.DomainModel.Group>().Where(g => g.Number == 1).ToList(); Assert.AreEqual(2, result.Count(), "Wrong groups count"); Assert.IsFalse(result.Any(g => g.Number != 1), "Wrong group returned"); }
public void GetGroupByID_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1" }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2" }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity<Group>(group1); db1Adapter.AddEntity<Group>(group2); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration<Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities<Mock.DomainModel.Group>().FirstOrDefault(g => g.ID == group1.Id); Assert.IsNotNull(result, "Event not found"); Assert.AreEqual(group1.Id, result.ID, "Wrong group"); }
public void GetGroup_GroupWithAttributeWithoutAdapterName_AdapterNameIsNull() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1" }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2" }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity<Group>(group1); db1Adapter.AddEntity<Group>(group2); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration<Mock.DB1_Context.Group, Mock.DomainModel.GroupWitoutSourceClass>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities<Mock.DomainModel.GroupAdapterNameNull>().FirstOrDefault(); }
public void GetGroupsWhereNumberEqual1_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1", Number = 1 }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2", Number = 1 }; var group3 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group3", Number = 2 }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity<Group>(group1); db1Adapter.AddEntity<Group>(group2); db1Adapter.AddEntity<Group>(group3); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration<Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name) .AddMap(s => s.Number, d => d.Number); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities<Mock.DomainModel.Group>().Where(g => g.Number == 1).ToList(); Assert.AreEqual(2, result.Count(), "Wrong groups count"); Assert.IsFalse(result.Any(g => g.Number != 1), "Wrong group returned"); }
public void GetGroupsSelectNewEntity_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1", Number = 1 }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2", Number = 1 }; var group3 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group3", Number = 2 }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity<Group>(group1); db1Adapter.AddEntity<Group>(group2); db1Adapter.AddEntity<Group>(group3); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration<Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name) .AddMap(s => s.Number, d => d.Number); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities<Mock.DomainModel.Group>() .Select(g => new { g.ID, g.Number }) .ToList(); Assert.IsTrue(result.Any(r => r.ID == group1.Id), "group1 is not found"); Assert.IsTrue(result.Any(r => r.ID == group2.Id), "group2 is not found"); Assert.IsTrue(result.Any(r => r.ID == group3.Id), "group3 is not found"); }
public void GetEventByGroupID_GroupFromDB1_EventFromDB2() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1" }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2" }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity<Group>(group1); db1Adapter.AddEntity<Group>(group2); db1Adapter.SaveChanges(); #region Mock.DB_2_Entities.Events Initialize var event1 = new Mock.DB2_Context.Event() { Id = Guid.NewGuid(), Name = "eventForGroup1", GroupName = group1.Name }; var event2 = new Mock.DB2_Context.Event() { Id = Guid.NewGuid(), Name = "eventForGroup2", GroupName = group2.Name }; #endregion var db2Adapter = new DB2Adapter(); db2Adapter.AddEntity<Event>(event1); db2Adapter.AddEntity<Event>(event2); db2Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration<Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); mapper.CreateConfiguration<Mock.DB2_Context.Event, Mock.DomainModel.Event>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); var cqContext = new CQContext(mapper, db1Adapter, db2Adapter); var result = cqContext.GetEntities<Mock.DomainModel.Event>().FirstOrDefault(e => e.Group.ID == group1.Id); Assert.IsNotNull(result, "Event not found"); Assert.AreEqual(event1.Id, result.ID, "Wrong event"); }
public void GetGroupsByNumberAndIdWhereWithAnd_GroupFromDB1() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1", Number = 1 }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2", Number = 1 }; var group3 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group3", Number = 2 }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity<Group>(group1); db1Adapter.AddEntity<Group>(group2); db1Adapter.AddEntity<Group>(group3); db1Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration<Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name) .AddMap(s => s.Number, d => d.Number); var cqContext = new CQContext(mapper, db1Adapter); var result = cqContext.GetEntities<Mock.DomainModel.Group>() .Where(g => g.Number == group1.Number && g.ID == group1.Id).First(); Assert.AreEqual(group1.Id, result.ID, "Wrong group returned"); }
public void GetEventByGroupID_GroupFromDB1_EventFromDB2() { #region Mock.DB_1_Entities.Groups Initialize var group1 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group1" }; var group2 = new Mock.DB1_Context.Group() { Id = Guid.NewGuid(), Name = "Group2" }; #endregion var db1Adapter = new DB1Adapter(); db1Adapter.AddEntity <Group>(group1); db1Adapter.AddEntity <Group>(group2); db1Adapter.SaveChanges(); #region Mock.DB_2_Entities.Events Initialize var event1 = new Mock.DB2_Context.Event() { Id = Guid.NewGuid(), Name = "eventForGroup1", GroupName = group1.Name }; var event2 = new Mock.DB2_Context.Event() { Id = Guid.NewGuid(), Name = "eventForGroup2", GroupName = group2.Name }; #endregion var db2Adapter = new DB2Adapter(); db2Adapter.AddEntity <Event>(event1); db2Adapter.AddEntity <Event>(event2); db2Adapter.SaveChanges(); var mapper = new Mapper.Mapper(); mapper.CreateConfiguration <Mock.DB1_Context.Group, Mock.DomainModel.Group>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); mapper.CreateConfiguration <Mock.DB2_Context.Event, Mock.DomainModel.Event>() .AddMap(s => s.Id, d => d.ID) .AddMap(s => s.Name, d => d.Name); var cqContext = new CQContext(mapper, db1Adapter, db2Adapter); var result = cqContext.GetEntities <Mock.DomainModel.Event>().FirstOrDefault(e => e.Group.ID == group1.Id); Assert.IsNotNull(result, "Event not found"); Assert.AreEqual(event1.Id, result.ID, "Wrong event"); }