public void CanDeserializeRssFeedFromXml() { var testfeed = TestFileLoader.GetSingleRssTestFilePath(TestFileLoader.TestFileType.FileSys); var feed = Factory.CreateFeed(new Uri(testfeed)); var serializer = new XmlSerializer(feed.GetType()); using (var filestream = new FileStream(RssXmlFile, FileMode.Create)) { serializer.Serialize(filestream, feed); } using (var readstream = new FileStream(RssXmlFile, FileMode.Open)) { using (var reader = XmlReader.Create(readstream)) { Assert.IsTrue(serializer.CanDeserialize(reader)); var resultantObject = serializer.Deserialize(reader); //Assert that the result object is of the expected type (some derivative of IFeed) Assert.IsInstanceOf(feed.GetType(), resultantObject); //Assert that the two objects are distinct instances Assert.AreNotSame(feed, resultantObject); //Cast the object back into an IFeed and perform some specific assertions var resultantFeed = resultantObject as IFeed; Assert.AreEqual(feed.Title, resultantFeed.Title); Assert.AreEqual(feed.LastUpdated, resultantFeed.LastUpdated); Assert.AreEqual(feed.FeedUri, resultantFeed.FeedUri); Assert.AreEqual(feed.FeedType, resultantFeed.FeedType); Assert.AreEqual(feed.Items.Count, resultantFeed.Items.Count); Assert.Pass("THE FEED CAN BE DESERIALIZED SUCCESSFULLY"); } } }
public async void ExpectCorrectStateAndExceptions() { var did = new Did("mstd:bpm").ToString(); var sut = cluster.GrainFactory.GetGrain <IBpmProcessGrain>(did); Assert.Equal(BpmProcessExecutionTypes.Uninitialized, sut.GetProcessStatus().Result); var ex = Assert.Throws <AggregateException>(() => sut.StartProcess().Wait()); Assert.EndsWith($"started.", ex.InnerException.Message); ex = Assert.Throws <AggregateException>(() => sut.PauseProcess().Wait()); Assert.EndsWith($"paused.", ex.InnerException.Message); ex = Assert.Throws <AggregateException>(() => sut.StopProcess().Wait()); Assert.EndsWith($"stopped.", ex.InnerException.Message); await sut.LoadProcess(TestFileLoader.Load(@"Bpmn20/simple-task.bpmn")); Assert.Equal(BpmProcessExecutionTypes.Initialized, sut.GetProcessStatus().Result); await sut.StartProcess(); Assert.Equal(BpmProcessExecutionTypes.Started, sut.GetProcessStatus().Result); await sut.PauseProcess(); Assert.Equal(BpmProcessExecutionTypes.Paused, sut.GetProcessStatus().Result); await sut.StopProcess(); Assert.Equal(BpmProcessExecutionTypes.Stopped, sut.GetProcessStatus().Result); }
public void CanFindAllMissingTests() { var httpTestCases = TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.Http); var fileSysTestCases = TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.FileSys); Assert.That(httpTestCases.Count >= 1, "There should be at least one Http test case for missing files."); Assert.That(fileSysTestCases.Count >= 1, "There should be at least one FileSys test case for missing files."); }
public void CanFindAllValidHttpTests() { var atomTestCases = TestFileLoader.LoadValidAtomTestCases(TestFileLoader.TestFileType.Http); var rssTestCases = TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.Http); var allTestCases = TestFileLoader.LoadAllValidTestCases(TestFileLoader.TestFileType.Http); Assert.That(rssTestCases.Count >= 1, "There should be at least one Rss test case."); Assert.That(atomTestCases.Count >= 1, "There should be at least one Atom test case."); Assert.That(allTestCases.Count >= 2, "There should be at least 2 test cases total."); Assert.That(allTestCases.Count == (rssTestCases.Count + atomTestCases.Count), "The number of test cases should be equal."); }
public void PatchTest(string jsonFileName) { //Arrange ApiAnything api = new ApiAnything(); var jsonString = TestFileLoader.LoadFromFile(jsonFileName); //Act var result = api.Patch(jsonString); var jsonResult = JObject.Parse(result.Content); //Assert Assert.True(JToken.DeepEquals(jsonString, jsonResult["data"])); }
public void GetTest(string jsonFileName) { //Arrange ApiAnything api = new ApiAnything(); var jsonString = TestFileLoader.LoadFromFile(jsonFileName); //Act var result = api.Get(jsonString); var jsonResult = JObject.Parse(result.Content); //Assert Assert.NotNull(jsonResult["json"]); }
public void CanFindAtomFileSysTests() { DirectoryInfo atomDir = new DirectoryInfo(TestFileLoader.ValidFileSysAtomTestDir); Assert.That(atomDir.Exists, string.Format("Atom test file directory [{0}] not found", TestFileLoader.ValidFileSysAtomTestDir)); var atomDirFiles = atomDir.GetFiles(TestFileLoader.TestFileSearchPattern); Assert.That(atomDirFiles.Length > 0, string.Format("No test files found in Atom test directory [{0}]", TestFileLoader.ValidFileSysAtomTestDir)); var testCases = TestFileLoader.LoadValidAtomTestCases(TestFileLoader.TestFileType.FileSys); Assert.That(atomDirFiles.Length == testCases.Count, string.Format("The number of files in the Atom directory [{0}] should match the number of test cases produced from them.", TestFileLoader.ValidFileSysAtomTestDir)); }
public void CanSerializeAtomFeedToXml() { var testfeed = TestFileLoader.GetSingleAtomTestFilePath(TestFileLoader.TestFileType.FileSys); var feed = Factory.CreateFeed(new Uri(testfeed)); var serializer = new XmlSerializer(feed.GetType()); using (var filestream = new FileStream(AtomXmlFile, FileMode.Create)) { serializer.Serialize(filestream, feed); } Assert.IsTrue(File.Exists(AtomXmlFile)); Assert.IsTrue(File.ReadAllText(AtomXmlFile).Length > 0); }
public void CanDetermineFlowTargetTypeThroughFactory() { var doc = XDocument.Parse(TestFileLoader.Load(@"Bpmn20/simple-exclusive-gateway.bpmn")); string json = JsonConvert.SerializeXNode(doc); JObject bpmn = JObject.Parse(json); var process = bpmn["bpmn:definitions"]["bpmn:process"]; var factory = new FlowTargetFactory(process, "Activity_A"); Assert.Equal("bpmn:task", factory.Target); var bpmnTask = new BpmnTask(factory.Token, new ExpressionContext()); factory = new FlowTargetFactory(process, "Gateway_1d2x0fd"); Assert.Equal("bpmn:exclusiveGateway", factory.Target); }
public async Task LoadsAndCombinesFiles() { var loader = new TestFileLoader(); var loaded = await loader.Load( new DirectoryInfo(RootPath("folder1", "folder2"))); Assert.That(loaded, Is.EqualTo(new[] { "Well", "hello", "there!", })); }
public void ExclusiveGatewayCanRead() { var doc = XDocument.Parse(TestFileLoader.Load(@"Bpmn20/simple-exclusive-gateway.bpmn")); string json = JsonConvert.SerializeXNode(doc); JObject bpmn = JObject.Parse(json); var process = bpmn["bpmn:definitions"]["bpmn:process"]; var factory = new FlowTargetFactory(process, "Gateway_1d2x0fd"); BpmExclusiveGateway gateway = new BpmExclusiveGateway(factory.Token); Assert.Equal("Gateway_1d2x0fd", gateway.Id); Assert.Single(gateway.Incoming); Assert.Equal("Flow_0hzr3el", gateway.Incoming[0]); Assert.Equal(2, gateway.Outgoing.Count); Assert.Equal("Flow_0gzbcgc", gateway.Outgoing[0]); Assert.Equal("Flow_1fg2zon", gateway.Outgoing[1]); }
public void ConditionalFlowCanReadAndEvaluateTFormalExpression() { var doc = XDocument.Parse(TestFileLoader.Load(@"Bpmn20/simple-exclusive-gateway.bpmn")); string json = JsonConvert.SerializeXNode(doc); JObject bpmn = JObject.Parse(json); var process = bpmn["bpmn:definitions"]["bpmn:process"]; var flow = process["bpmn:sequenceFlow"].Where(p => p["@id"].Value <string>() == "Flow_0gzbcgc").Single()["bpmn:conditionExpression"]["#text"]; ExpressionContext context = new ExpressionContext(); context.Variables["A"] = 1; IGenericExpression <bool> eDynamic = context.CompileGeneric <bool>((string)flow); var result = eDynamic.Evaluate(); Assert.True(result); flow = process["bpmn:sequenceFlow"].Where(p => p["@id"].Value <string>() == "Flow_1fg2zon").Single()["bpmn:conditionExpression"]["#text"]; eDynamic = context.CompileGeneric <bool>((string)flow); result = eDynamic.Evaluate(); Assert.False(result); }
public AsyncHttpFeedFactoryTests() : base(TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.Http)) { Factory = new HttpFeedFactory(); FeedType = FeedType.Rss20; }
public SimpleTaskTests(ITestOutputHelper output) { Output = output; process = new BpmnProcess(TestFileLoader.Load(@"Bpmn20/simple-task.bpmn")); }
public void CanReadSomeSimpleTasks() { var doc = XDocument.Parse(TestFileLoader.Load(@"Bpmn20/simple-task.bpmn")); string json = JsonConvert.SerializeXNode(doc); JObject rss = JObject.Parse(json); var process = rss["bpmn:definitions"]["bpmn:process"]; var startEvent = process["bpmn:startEvent"]["bpmn:outgoing"].Value <string>(); Output.WriteLine($"process start event: {startEvent}."); var endEvent = process["bpmn:endEvent"]["bpmn:incoming"].Value <string>(); // step through the sequence string step = startEvent; while (step != endEvent) { var sequence = process["bpmn:sequenceFlow"].Single(p => p.Value <string>("@id") == step); var target = sequence["@targetRef"].Value <string>(); // find target ref in tasks. var task = process["bpmn:task"].Where(p => p.Value <string>("@id") == target).Single(); var doc2 = task["@name"].Value <string>(); var incoming = task["bpmn:incoming"].Value <string>(); Assert.Equal(step, incoming); var outgoing = task["bpmn:outgoing"].Value <string>(); // execution listener var ext = task["bpmn:extensionElements"]; if (ext != null) { var listener = ext["camunda:executionListener"]; if (listener != null) { var exp = listener["@delegateExpression"].Value <string>(); // triggered at start of task or end. var evtType = listener["@event"].Value <string>(); var io = ext["camunda:inputOutput"]; if (io != null) { var parameters = new System.Collections.Generic.Dictionary <string, string>(); foreach (var item in io["camunda:outputParameter"].Children()) { var name = item["@name"].Value <string>(); var value = item["#text"].Value <string>(); parameters.Add(name, value); } Assert.Equal(4, parameters.Count); Assert.Equal("*****@*****.**", parameters["From"]); Assert.Equal("*****@*****.**", parameters["To"]); Assert.Equal("This a Test Email Topic", parameters["Topic"]); Assert.Equal("This is the body of the email message", parameters["Content"]); } } } Output.WriteLine($"step executing task {target}: '{doc2}'. Next step {outgoing}."); step = outgoing; } Output.WriteLine($"process end event: {endEvent}."); }
public void LoadBpmn(string path) { Process = new BpmnProcess(TestFileLoader.Load(path)); }
public MissingFileSysFeedFactoryTests() : base(new FileSystemFeedFactory(), FeedType.Rss20, TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.FileSys)) { }
public HttpFeedFactoryTestsRss() : base(new HttpFeedFactory(), QDFeedParser.FeedType.Rss20, TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.Http)) { }
public FileFeedFactoryTestsRss() : base(new FileSystemFeedFactory(), FeedType.Rss20, TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.FileSys)) { }
public AsyncMissingHttpFeedFactoryTests() : base(TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.Http)) { Factory = new HttpFeedFactory(); FeedType = FeedType.Rss20; }
public FileFeedFactoryTestsAtom() : base(new FileSystemFeedFactory(), FeedType.Atom10, TestFileLoader.LoadValidAtomTestCases(TestFileLoader.TestFileType.FileSys)) { }
public MissingHttpFeedFactoryTests() : base(new HttpFeedFactory(), FeedType.Rss20, TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.Http)) { }
public AtomFeedTest() : base(new FileSystemFeedFactory(), TestFileLoader.LoadValidAtomTestCases(TestFileLoader.TestFileType.FileSys)) { }
public AsyncMissingFileSysFeedFactoryTest() : base(TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.FileSys)) { Factory = new FileSystemFeedFactory(); FeedType = FeedType.Rss20; }
public HttpFeedFactoryTestsAtom() : base(new HttpFeedFactory(), FeedType.Atom10, TestFileLoader.LoadValidAtomTestCases(TestFileLoader.TestFileType.Http)) { }
public void SetUp() { this.Factory = new FileSystemFeedFactory(); feeduri = new Uri(TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.FileSys).First().Arguments[0].ToString()); itemCount = 3; }
public AsyncFileSysFeedFactoryTests() : base(TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.FileSys)) { Factory = new FileSystemFeedFactory(); FeedType = FeedType.Rss20; }