public void TestInvalidAnswer() { IDataSource dataSource = new DataSource.DataSource(BuildStaticDoughnutTree()); IDecisionService service = new DecisionService(dataSource); Assert.Throws <NodeNotFoundException>(() => service.GetCurrentQuestion(new List <bool> { false, false })); Assert.Throws <NodeNotFoundException>(() => service.GetCurrentQuestion(new List <bool> { true, true, true, true })); Assert.Throws <NodeNotFoundException>(() => service.GetCurrentQuestion(new List <bool> { true, true, false, true })); Assert.Throws <NodeNotFoundException>(() => service.GetCurrentQuestion(new List <bool> { true, true, false, false })); Assert.Throws <NodeNotFoundException>(() => service.GetCurrentQuestion(new List <bool> { true, false, true, false })); Assert.Throws <NodeNotFoundException>(() => service.GetCurrentQuestion(new List <bool> { true, false, false, false })); //Assert.(3, _service.GetTreeMaxpath()); }
public void TestFirstQuestion() { IDataSource dataSource = new DataSource.DataSource(BuildStaticDoughnutTree()); IDecisionService _service = new DecisionService(dataSource); Assert.Equal(dataSource.DecisionTree.Statement, _service.GetFirstQuestion()); //Assert.(3, _service.GetTreeMaxpath()); }
public void TestNullDatasourceHandeler() { IDataSource dataSource = new DataSource.DataSource(null); IDecisionService service = new DecisionService(dataSource); Assert.Throws <NodeNotFoundException>(() => service.GetFirstQuestion()); Assert.Throws <NodeNotFoundException>(() => service.GetFirstNode()); Assert.Null(service.GetFullTree()); //Assert.(3, _service.GetTreeMaxpath()); }
public void TestNextQuestion() { IDataSource dataSource = new DataSource.DataSource(BuildStaticDoughnutTree()); IDecisionService service = new DecisionService(dataSource); Assert.Equal(dataSource.DecisionTree.LeafN.Statement, service.GetCurrentQuestion(new List <bool> { false })); //Assert.(3, _service.GetTreeMaxpath()); }
public void MaxPath() { IDataSource dataSource = new DataSource.DataSource(); IDecisionService service = new DecisionService(dataSource); Assert.True(service.GetTreeMaxpath() >= 3); dataSource = new DataSource.DataSource(null); service = new DecisionService(dataSource); Assert.True(service.GetTreeMaxpath() == 0); }
public void TestValidNoad() { IDataSource dataSource = new DataSource.DataSource(BuildStaticDoughnutTree()); INode node = DeepCopier.Copy(dataSource.DecisionTree); IDecisionService service = new DecisionService(dataSource); Assert.True(JsonConvert.SerializeObject(node.LeafY).Equals(JsonConvert.SerializeObject(service.GetClildTree(new List <bool> { true })))); Assert.True(JsonConvert.SerializeObject(node.LeafY.LeafY).Equals(JsonConvert.SerializeObject(service.GetClildTree(new List <bool> { true, true })))); Assert.True(JsonConvert.SerializeObject(node.LeafY.LeafY.LeafY).Equals(JsonConvert.SerializeObject(service.GetClildTree(new List <bool> { true, true, true })))); Assert.True(JsonConvert.SerializeObject(node.LeafN).Equals(JsonConvert.SerializeObject(service.GetClildTree(new List <bool> { false })))); }
public static void Main(string[] parameters) { // your code goes here DatabaseStore _dbs = new DatabaseStore(); DistributedCacheStore _dcs = new DistributedCacheStore(); DataSource.DataSource _ds = new DataSource.DataSource(_dcs); // Attach for (int k = 0; k < 10; k++) { _dbs.StoreValue("key" + k, "value" + k); //Populate DatabaseStore with data _dcs.StoreValue("key" + k, "value" + k); //Distribute Data to DistributedCacheStore for current default "working node" } for (var i = 0; i < 10; i++) { new Thread(() => { // your code goes here Random rnd = new Random(); Stopwatch stopWatch = new Stopwatch(); string key = string.Empty; object d; for (int t = 0; t < 50; t++) { key = "key" + rnd.Next(0, 9); stopWatch.Reset(); stopWatch.Start(); d = _ds.GetValue(key); stopWatch.Stop(); Console.WriteLine("[{0}] Request '{1}', response '{2}', time: {3} ms", Thread.CurrentThread.ManagedThreadId, key, d as string, stopWatch.ElapsedMilliseconds.ToString("0.00")); } }).Start(); } Console.ReadKey(); }