Exemplo n.º 1
0
        public void InitialJaggedBoardSerializesProperly()
        {
            var    board      = new JaggedChessBoard();
            var    serializer = new Serializer();
            string xml        = serializer.SerializeObject(board);

            Approvals.VerifyXml(xml);
        }
Exemplo n.º 2
0
        public void ensure_wsdl_is_stable()
        {
            const string address = "http://localhost:11111/hello";

            using (var host = CreateAndOpenHost(address))
            {
                var wsdl = new HttpClient().GetStringAsync($"{address}?singleWsdl").Result;

                Approvals.VerifyXml(wsdl);
            }
        }
        public void SerializeDogResultsInExpectedOutput()
        {
            var dog = new Dog("Fido", "Golden Retriever", true, null)
            {
                BirthDate = new DateTime(2003, 5, 10),
                Collar    = DogCollarFactory.GetCollar(20, true)
            };
            var serializer = new Serializer();

            serializer.RegisterType <Dog>().ToTypeSerializer <DogSerializer>().WithConstructorArgument("title", "King");
            string xml = serializer.SerializeObject(dog);

            Approvals.VerifyXml(xml);
        }
Exemplo n.º 4
0
        public void Process_EmbedConfig()
        {
            using (var inputWsdlStream = typeof(FilteringTests).Assembly.GetManifestResourceStream("WsdlFilter.Tests.Calculator.wsdl"))
            {
                var sd = ServiceDescription.Read(inputWsdlStream);
                var wsdlProcessingOptions = new WsdlProcessingOptions(removeDocumentation: false, removePortTypes: null, keepOperations: null, convertToFireAndForget: null, embedCommandLineConfig: true, "--input=input.wsdl --output=output.wsdl");

                sd.Process(wsdlProcessingOptions);

                using (var wsdlOutputStream = new StringWriter())
                {
                    sd.Write(wsdlOutputStream);

                    Approvals.VerifyXml(wsdlOutputStream.ToString());
                }
            }
        }
        public void SingleEpochXMLPersistence()
        {
            var sb  = new System.Text.StringBuilder();
            var sxw = XmlWriter.Create(sb);
            var gID = new Guid("a5839fe9-90ef-4e39-bf26-8f75048306a3");
            var exp = new EpochXMLPersistor(sxw, () => gID);

            var g1ID       = new Guid("a5839fe9-90ef-4e39-bf26-8f75048306f3");
            var startTime1 = new DateTimeOffset(2011, 8, 22, 11, 12, 0, 0, TimeSpan.FromHours(-6));

            exp.BeginEpochGroup("label", "source", new string[0], new Dictionary <string, object>(), g1ID, startTime1);
            RunSingleEpoch(5, 2, exp);
            exp.EndEpochGroup();

            exp.Close();

            Approvals.VerifyXml(sb.ToString());
        }
        //[UseReporter(typeof(DiffReporter))]
        public void ShouldAllowNestedEpochGroupsInXML()
        {
            StringBuilder sb  = new System.Text.StringBuilder();
            var           sxw = XmlWriter.Create(sb);
            var           exp = new EpochXMLPersistor(sxw);

            const string label1     = "label1";
            const string label2     = "label2";
            var          g1ID       = new Guid("a5839fe9-90ef-4e39-bf26-8f75048306f3");
            var          g2ID       = new Guid("a5839fe9-90ef-4e39-bf26-8f75048306f4");
            var          startTime1 = new DateTimeOffset(2011, 8, 22, 11, 12, 0, 0, TimeSpan.FromHours(-6));
            var          startTime2 = new DateTimeOffset(2011, 8, 22, 11, 15, 0, 0, TimeSpan.FromHours(-6));

            exp.BeginEpochGroup(label1, "", new string[0], new Dictionary <string, object>(), g1ID, startTime1);

            exp.BeginEpochGroup(label2, "source", new string[0], new Dictionary <string, object>(), g2ID, startTime2);
            exp.EndEpochGroup();

            exp.Close();

            Approvals.VerifyXml(sb.ToString());
        }
        public void ShouldAllowLongStringEpochParameters()
        {
            if (File.Exists("..\\..\\..\\ShouldAllowLongStringEpochParameters.h5"))
            {
                File.Delete("..\\..\\..\\ShouldAllowLongStringEpochParameters.h5");
            }

            var gID = new Guid("{2F2719F7-4A8C-4C22-9698-BE999DBC5385}");

            using (
                var exp = new EpochHDF5Persistor("..\\..\\..\\ShouldAllowLongStringEpochParameters.h5", null, () => gID)
                )
            {
                var time  = new DateTimeOffset(1000, TimeSpan.Zero);
                var guid  = new Guid("053C64D4-ED7A-4128-AA43-ED115716A97D");
                var props = new Dictionary <string, object>();
                props["key1"] =
                    "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
                //100 elements
                props["key2"] = 2;

                const string protocolID = "Epoch.Fixture";
                Dictionary <string, object> parameters = props;

                dev1 = new UnitConvertingExternalDevice(dev1Name, "DEVICECO", new Measurement(0, "V"));
                dev2 = new UnitConvertingExternalDevice(dev2Name, "DEVICECO", new Measurement(0, "V"));

                var stream1 = new DAQInputStream("Stream1");
                var stream2 = new DAQInputStream("Stream2");

                var stimParameters = new Dictionary <string, object>();
                stimParameters[param1] = value1;
                stimParameters[param2] = value2;

                var srate = new Measurement(1000, "Hz");

                List <Measurement> samples =
                    Enumerable.Range(0, 10000).Select(i => new Measurement((decimal)Math.Sin((double)i / 100), "mV")).
                    ToList();
                var stimData = new OutputData(samples, srate, false);

                var stim1 = new RenderedStimulus("RenderedStimulus", stimParameters, stimData);
                //.Data does not need to be persisted
                var stim2 = new RenderedStimulus("RenderedStimulus", stimParameters, stimData);
                //.Data does not need to be persisted

                var e = new Epoch(protocolID, parameters);
                e.Stimuli[dev1] = stim1;
                e.Stimuli[dev2] = stim2;

                DateTimeOffset start = DateTimeOffset.Parse("1/11/2011 6:03:29 PM -08:00");
                // Do this to match the XML stored in the EpochXML.txt resource
                e.StartTime = Maybe <DateTimeOffset> .Yes(start);

                e.Background[dev1] = new Epoch.EpochBackground(new Measurement(0, "V"), new Measurement(1000, "Hz"));
                e.Background[dev2] = new Epoch.EpochBackground(new Measurement(1, "V"), new Measurement(1000, "Hz"));

                e.Responses[dev1] = new Response();
                e.Responses[dev2] = new Response();

                var streamConfig = new Dictionary <string, object>();
                streamConfig[param1] = value1;

                var devConfig = new Dictionary <string, object>();
                devConfig[param2] = value2;

                IInputData responseData1 = new InputData(samples, srate, start)
                                           .DataWithStreamConfiguration(stream1, streamConfig)
                                           .DataWithExternalDeviceConfiguration(dev1, devConfig);
                IInputData responseData2 = new InputData(samples, srate, start)
                                           .DataWithStreamConfiguration(stream2, streamConfig)
                                           .DataWithExternalDeviceConfiguration(dev2, devConfig);

                e.Responses[dev1].AppendData(responseData1);
                e.Responses[dev2].AppendData(responseData2);

                e.Keywords.Add(kw1);
                e.Keywords.Add(kw2);

                exp.BeginEpochGroup("label", "source identifier", new[] { "keyword1", "keyword2" }, props, guid,
                                    time);

                exp.Serialize(e);

                exp.EndEpochGroup(time.AddMilliseconds(100));
                exp.Close();
            }

            H5.Close();

            var startInfo = new ProcessStartInfo(@"..\..\..\..\..\..\externals\HDF5\bin\h5dump",
                                                 @" --xml ..\..\..\ShouldAllowLongStringEpochParameters.h5");

            startInfo.RedirectStandardOutput = true;
            startInfo.UseShellExecute        = false;
            Process proc = Process.Start(startInfo);

            Approvals.VerifyXml(proc.StandardOutput.ReadToEnd());
        }
Exemplo n.º 8
0
        public void WhenExecutingServiceConfigurationTransform_ThenCorrectlyTransformExampleFile()
        {
            var result = PerformXdtTransform(ExampleServiceConfiguration, XdtServiceConfiguration);

            Approvals.VerifyXml(result);
        }
Exemplo n.º 9
0
        public void WhenExecutingCloudProjectTransform_ThenCorrectlyTransformExampleFile()
        {
            var result = PerformXdtTransform(ExampleCloudProject, XdtCloudProject);

            Approvals.VerifyXml(result);
        }