public void Then_SectionEndsUpInAppropriateSource() { DummySection sectionFromSource1 = (DummySection)ChildSource1.GetSection(SectionInChildSource1); Assert.IsNotNull(sectionFromSource1); Assert.AreEqual("NewSection", sectionFromSource1.Name); }
protected override void Act() { DummySection dummySectionBeforeChange = (DummySection)MainSource.GetSection(SectionInChildSource1); var sourcesSection = CreateConfigurationSourceSection(); var redirect = sourcesSection.RedirectedSections.Where(x => x.Name == SectionInChildSource1).First(); redirect.SourceName = "Source2"; MainSource.Remove(ConfigurationSourceSection.SectionName); MainSource.Add(ConfigurationSourceSection.SectionName, sourcesSection); MainSource.DoSourceChanged(new [] { ConfigurationSourceSection.SectionName }); try { MainSource.GetSection(SectionInChildSource1); Assert.Fail(); // Getting here indicates the section is still in original source } catch (ConfigurationSourceErrorsException) { // not caught intentionally } ChildSource2 = (TestConfigurationSource)CompositionHandler["Source2"]; ChildSource2.Add(SectionInChildSource1, new DummySection { Name = "SectionInSource2" }); }
protected virtual ConfigurationSection ArrangeOriginalSection() { var section = new DummySection { Name = "TestName", Value = 42 }; return(section); }
protected override void Act() { section = CompositeSource.GetSection(FileSourceDummySectionName) as DummySection; File.SetLastWriteTime(@"ExternalFileSource.config", DateTime.Now.AddSeconds(1.0)); // Wait for at least two events Assert.IsTrue(waitForChangedEvents.Wait(30000), "timed out"); }
protected override void Arrange() { base.Arrange(); section = new DummySection { Name = "NewSection", Value = 21 }; }
protected override void Act() { DummySection dummySectionBeforeChange = (DummySection)MainSource.GetSection(SectionInChildSource1); ChildSource1.Remove(SectionInChildSource1); ChildSource1.Add(SectionInChildSource1, new DummySection { Name = "new name", Value = 16 }); ChildSource1.DoSourceChanged(new[] { SectionInChildSource1 }); }
protected override void Act() { section = CompositeSource.GetSection(FileSourceDummySectionName) as DummySection; File.SetLastWriteTime(@"ExternalFileSource.config", DateTime.Now); // Wait for at least two events Assert.IsTrue(waitForChangedEvents.Wait(30000), "timed out"); // And give it a little more time in case more come in Thread.Sleep(3000); }
protected override void Arrange() { base.Arrange(); var customSourceContents = new Dictionary <string, System.Configuration.ConfigurationSection>(); customSourceContents.Add(CustomSourceDummySectionName, sectionInCustomSource = new DummySection { Value = 12, Name = CustomSourceDummySectionName }); TestConfigurationSource.ConfigurationSourceContents = customSourceContents; }
public void BeforeEach() { _sectionProvider = new Mock <ISectionProvider>(); _typeFactory = new Mock <ITypeFactory>(); _mappingFactory = new Mock <IMappingFactory>(); _strategyManager = new Mock <IStrategyManager>(); _mappingStrategy = new Mock <IMappingStrategy>(); _typeMapping = new Mock <ITypeMapping>(); _xElement = new XElement("element"); _section = new DummySection(_xElement); _fooInstance = new Foo(); _sectionProvider.Setup(sp => sp.GetSection <IFoo>(_mappingStrategy.Object)).Returns(_section); _strategyManager.Setup(sm => sm.GetStrategyFor <IFoo>()).Returns(_mappingStrategy.Object); _typeFactory.Setup(tf => tf.InstanceOf(typeof(IFoo))).Returns(_fooInstance); _mappingFactory.Setup(mf => mf.CreateMapping(typeof(Foo), _xElement, _mappingStrategy.Object)) .Returns(_typeMapping.Object); _engine = new MappingEngine(_sectionProvider.Object, _typeFactory.Object, _mappingFactory.Object, _strategyManager.Object); }
protected override void Act() { section = (DummySection)CompositeSource.GetSection(FileSourceDummySectionName); }
public void Then_MethodReturnsConfiguationSection() { DummySection section = (DummySection)CompositeSource.GetSection(PointsToSelfSourceDummySectionName); Assert.IsNotNull(section); }
protected override void Act() { section = (DummySection)MergedSource.GetSection(FileSourceDummySectionName); }
internal override void Read(BinaryReaderEx br) { br.BigEndian = false; br.AssertASCII("MSB "); br.AssertInt32(1); // Header size/data start br.AssertInt32(0x10); // Probably bytes, just guessing br.AssertByte(0); br.AssertByte(0); br.AssertByte(1); br.AssertByte(0xFF); Entries entries = default; long nextSectionOffset = br.Position; while (nextSectionOffset != 0) { br.Position = nextSectionOffset; int unk1 = br.ReadInt32(); int offsets = br.ReadInt32() - 1; long typeOffset = br.ReadInt64(); string type = br.GetUTF16(typeOffset); switch (type) { case "MODEL_PARAM_ST": Models = new ModelSection(br, unk1); entries.Models = Models.Read(br, offsets, Version); break; case "EVENT_PARAM_ST": Events = new EventSection(br, unk1); entries.Events = Events.Read(br, offsets, Version); break; case "POINT_PARAM_ST": Regions = new PointSection(br, unk1); entries.Regions = Regions.Read(br, offsets, Version); break; case "ROUTE_PARAM_ST": Routes = new RouteSection(br, unk1); entries.Routes = Routes.Read(br, offsets, Version); break; case "LAYER_PARAM_ST": Layers = new LayerSection(br, unk1); entries.Layers = Layers.Read(br, offsets, Version); break; case "PARTS_PARAM_ST": Parts = new PartsSection(br, unk1); entries.Parts = Parts.Read(br, offsets, Version); break; case "MAPSTUDIO_PARTS_POSE_ST": PartsPoses = new DummySection(br, unk1, type, offsets); break; case "MAPSTUDIO_BONE_NAME_STRING": BoneNames = new BoneNameSection(br, unk1); entries.BoneNames = BoneNames.Read(br, offsets, Version); break; default: throw new NotImplementedException($"Unimplemented section: {type}"); } nextSectionOffset = br.ReadInt64(); } Events.GetNames(this, entries); Parts.GetNames(this, entries); }
public void Then_SectionCanBeAccessedFromMainSource() { DummySection sectionFromMainSource = (DummySection)MainSource.GetSection(SectionInChildSource1); }
public void Then_CompositeSourceReturnsUpdatedSectionFromOtherSource() { DummySection dummySectionAfterChange = (DummySection)MainSource.GetSection(SectionInChildSource1); Assert.AreEqual("SectionInSource2", dummySectionAfterChange.Name); }
public void Then_CompositeSourceReturnsUpdatedConfigurationSection() { DummySection dummySectionAfterChange = (DummySection)MainSource.GetSection(SectionInChildSource1); Assert.AreEqual("new name", dummySectionAfterChange.Name); }