protected override void Load(ContainerBuilder builder) { var schoolCollection = new SchoolCollection(); schoolCollection.Add(new School { Identifier = identifiers[0], ID = 1, Name = "test1" }); schoolCollection.Add(new School { Identifier = identifiers[1], ID = 2, Name = "test2" }); schoolCollection.Add(new School { Identifier = identifiers[2], ID = 3, Name = "test3" }); schoolCollection.Add(new School { Identifier = identifiers[3], ID = 4, Name = "test4" }); schoolCollection.Add(new School { Identifier = identifiers[4], ID = 5, Name = "test5" }); var metaRepoMock = new Mock <IMetaRepository>(); metaRepoMock.Setup(r => r.GetAllSchools()).Returns(schoolCollection); metaRepoMock.Setup(r => r.AddOrUpdateSchool( It.IsAny <School>(), It.IsAny <Action <bool> >())) .Callback <School, Action <bool> >((school, action) => { new Task(() => { action(true); }).Start(); }); var identifierMock = new Mock <IIdentifierProvider>(); identifierMock.Setup(r => r.GetIdentifier()).Returns(identifiers[count++]); builder.Register(c => identifierMock.Object).As <IIdentifierProvider>(); builder.Register(c => metaRepoMock.Object).As <IMetaRepository>(); }
protected override void Load(ContainerBuilder builder) { var schoolCollection = new SchoolCollection(); schoolCollection.Add(new School { Identifier = "098f6bcd4621d373cade4e832627b4f6", ID = 1, Name = "test" }); var metaRepoMock = new Mock<IMetaRepository>(); metaRepoMock.Setup(r => r.GetAllSchools()).Returns(schoolCollection); metaRepoMock.Setup(r => r.AddOrUpdateSchool( It.IsAny<School>(), It.IsAny<Action<bool>>())) .Callback<School, Action<bool>>((school, action) => { var model = schoolCollection.ByIdentifier(school.Identifier); model.UniqueToken = school.UniqueToken; new Task(() => { System.Threading.Thread.Sleep(500); action(true); }).Start(); }); builder.Register(c => new TestIdentityProvider()).As<IIdentifierProvider>(); builder.Register(c => new TestRsaKeyProvider()).As<ICryptoKeyProvider>(); builder.Register(c => metaRepoMock.Object).As<IMetaRepository>().SingleInstance(); builder.Register((c, p) => new SampleCommand( p.Named<IoSession>("session"), c.ResolveOptional<TimeoutNotifyProducerConsumer<AbstractAsyncCommand>>() )).Keyed<AbstractAsyncCommand>(CommandCode.Test); }
public MetaTestRepo() { schoolCollection = new SchoolCollection(); schoolCollection.Add(new School { Identifier = "098f6bcd4621d373cade4e832627b4f6", ID = 1, Name = "test" }); }
public Models.Api.SchoolListClassifiedRS GetSchoolListClassified(ApiRequest apiRQ) { var schoolCollection1 = new SchoolCollection(); schoolCollection1.Add(new School { ID = 1, Name = "上海海富幼儿园龙阳校区" }); schoolCollection1.Add(new School { ID = 2, Name = "上海私立蒙特梭利幼儿园" }); schoolCollection1.Add(new School { ID = 3, Name = "上海市建青实验学校幼儿部" }); schoolCollection1.Add(new School { ID = 4, Name = "上海中国福利会幼儿园" }); schoolCollection1.Add(new School { ID = 5, Name = "上海市浦东新区冰厂田幼儿园(云山路寄宿部)" }); var area1 = new Area { ID = 1, Name = "黄浦区", Schools = schoolCollection1 }; var schoolCollection2 = new SchoolCollection(); schoolCollection2.Add(new School { ID = 6, Name = "上海市实验幼儿园(杏山园)" }); schoolCollection2.Add(new School { ID = 7, Name = "孔祥东音乐幼儿园(巨野路园区)" }); schoolCollection2.Add(new School { ID = 8, Name = "上海市徐汇区科技幼儿园" }); var area2 = new Area { ID = 2, Name = "徐汇区", Schools = schoolCollection2 }; var schoolCollection3 = new SchoolCollection(); schoolCollection3.Add(new School { ID = 9, Name = "上海乌南幼儿园" }); schoolCollection3.Add(new School { ID = 10, Name = "上海市本溪路幼儿园" }); schoolCollection3.Add(new School { ID = 11, Name = "上海市宝山区行知实验幼儿园" }); var area3 = new Area { ID = 3, Name = "长宁区", Schools = schoolCollection3 }; var areaCollection1 = new AreaCollection(); areaCollection1.Add(area1); areaCollection1.Add(area2); areaCollection1.Add(area3); var schoolCollection4 = new SchoolCollection(); schoolCollection4.Add(new School { ID = 12, Name = "宁波市第一幼儿园" }); schoolCollection4.Add(new School { ID = 13, Name = "宁波市宝韵音乐幼儿园" }); schoolCollection4.Add(new School { ID = 14, Name = "宁波市华光幼儿园" }); var schoolCollection5 = new SchoolCollection(); schoolCollection5.Add(new School { ID = 15, Name = "杭州市行知幼儿园" }); schoolCollection5.Add(new School { ID = 16, Name = "杭州市清波幼儿园" }); schoolCollection5.Add(new School { ID = 17, Name = "杭州市娃哈哈幼儿园" }); var area4 = new Area { ID = 4, Name = "杭州市", Schools = schoolCollection5 }; var area5 = new Area { ID = 5, Name = "宁波市", Schools = schoolCollection4 }; var areaCollection2 = new AreaCollection(); areaCollection2.Add(area4); areaCollection2.Add(area5); var sh = new Province { ID = 1, Areas = areaCollection1, Name = "上海市" }; var zj = new Province { ID = 2, Areas = areaCollection2, Name = "浙江省" }; return new SchoolListClassifiedRS { Ok = true, Provinces = new List<Province> { sh, zj } }; }
protected override void Load(ContainerBuilder builder) { var schoolCollection = new SchoolCollection(); schoolCollection.Add(new School { Identifier = "098f6bcd4621d373cade4e832627b4f6", ID = 1, Name = "test" }); var metaRepoMock = new Mock <IMetaRepository>(); metaRepoMock.Setup(r => r.GetAllSchools()).Returns(schoolCollection); metaRepoMock.Setup(r => r.AddOrUpdateSchool( It.IsAny <School>(), It.IsAny <Action <bool> >())) .Callback <School, Action <bool> >((school, action) => { var model = schoolCollection.ByIdentifier(school.Identifier); model.UniqueToken = school.UniqueToken; new Task(() => { System.Threading.Thread.Sleep(500); action(true); }).Start(); }); builder.Register(c => new TestIdentityProvider()).As <IIdentifierProvider>(); builder.Register(c => new TestRsaKeyProvider()).As <ICryptoKeyProvider>(); builder.Register(c => metaRepoMock.Object).As <IMetaRepository>().SingleInstance(); builder.Register((c, p) => new SampleCommand( p.Named <IoSession>("session"), c.ResolveOptional <TimeoutNotifyProducerConsumer <AbstractAsyncCommand> >() )).Keyed <AbstractAsyncCommand>(CommandCode.Test); }
protected override void Load(ContainerBuilder builder) { var schoolCollection = new SchoolCollection(); schoolCollection.Add(new School { Identifier = identifiers[0], ID = 1, Name = "test1" }); schoolCollection.Add(new School { Identifier = identifiers[1], ID = 2, Name = "test2" }); schoolCollection.Add(new School { Identifier = identifiers[2], ID = 3, Name = "test3" }); schoolCollection.Add(new School { Identifier = identifiers[3], ID = 4, Name = "test4" }); schoolCollection.Add(new School { Identifier = identifiers[4], ID = 5, Name = "test5" }); var metaRepoMock = new Mock<IMetaRepository>(); metaRepoMock.Setup(r => r.GetAllSchools()).Returns(schoolCollection); metaRepoMock.Setup(r => r.AddOrUpdateSchool( It.IsAny<School>(), It.IsAny<Action<bool>>())) .Callback<School, Action<bool>>((school, action) => { new Task(() => { action(true); }).Start(); }); var identifierMock = new Mock<IIdentifierProvider>(); identifierMock.Setup(r => r.GetIdentifier()).Returns(identifiers[count++]); builder.Register(c => identifierMock.Object).As<IIdentifierProvider>(); builder.Register(c => metaRepoMock.Object).As<IMetaRepository>(); }
public Models.Api.SchoolListClassifiedRS GetSchoolListClassified(ApiRequest apiRQ) { var schoolCollection1 = new SchoolCollection(); schoolCollection1.Add(new School { ID = 1, Name = "上海海富幼儿园龙阳校区" }); schoolCollection1.Add(new School { ID = 2, Name = "上海私立蒙特梭利幼儿园" }); schoolCollection1.Add(new School { ID = 3, Name = "上海市建青实验学校幼儿部" }); schoolCollection1.Add(new School { ID = 4, Name = "上海中国福利会幼儿园" }); schoolCollection1.Add(new School { ID = 5, Name = "上海市浦东新区冰厂田幼儿园(云山路寄宿部)" }); var area1 = new Area { ID = 1, Name = "黄浦区", Schools = schoolCollection1 }; var schoolCollection2 = new SchoolCollection(); schoolCollection2.Add(new School { ID = 6, Name = "上海市实验幼儿园(杏山园)" }); schoolCollection2.Add(new School { ID = 7, Name = "孔祥东音乐幼儿园(巨野路园区)" }); schoolCollection2.Add(new School { ID = 8, Name = "上海市徐汇区科技幼儿园" }); var area2 = new Area { ID = 2, Name = "徐汇区", Schools = schoolCollection2 }; var schoolCollection3 = new SchoolCollection(); schoolCollection3.Add(new School { ID = 9, Name = "上海乌南幼儿园" }); schoolCollection3.Add(new School { ID = 10, Name = "上海市本溪路幼儿园" }); schoolCollection3.Add(new School { ID = 11, Name = "上海市宝山区行知实验幼儿园" }); var area3 = new Area { ID = 3, Name = "长宁区", Schools = schoolCollection3 }; var areaCollection1 = new AreaCollection(); areaCollection1.Add(area1); areaCollection1.Add(area2); areaCollection1.Add(area3); var schoolCollection4 = new SchoolCollection(); schoolCollection4.Add(new School { ID = 12, Name = "宁波市第一幼儿园" }); schoolCollection4.Add(new School { ID = 13, Name = "宁波市宝韵音乐幼儿园" }); schoolCollection4.Add(new School { ID = 14, Name = "宁波市华光幼儿园" }); var schoolCollection5 = new SchoolCollection(); schoolCollection5.Add(new School { ID = 15, Name = "杭州市行知幼儿园" }); schoolCollection5.Add(new School { ID = 16, Name = "杭州市清波幼儿园" }); schoolCollection5.Add(new School { ID = 17, Name = "杭州市娃哈哈幼儿园" }); var area4 = new Area { ID = 4, Name = "杭州市", Schools = schoolCollection5 }; var area5 = new Area { ID = 5, Name = "宁波市", Schools = schoolCollection4 }; var areaCollection2 = new AreaCollection(); areaCollection2.Add(area4); areaCollection2.Add(area5); var sh = new Province { ID = 1, Areas = areaCollection1, Name = "上海市" }; var zj = new Province { ID = 2, Areas = areaCollection2, Name = "浙江省" }; return(new SchoolListClassifiedRS { Ok = true, Provinces = new List <Province> { sh, zj } }); }