Esempio n. 1
0
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.SimpleHostBotComposerDotNet,
                HostBot.SimpleHostBotDotNet,
                HostBot.SimpleHostBotJS,
                HostBot.SimpleHostBotPython,
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.EchoSkillBotComposerDotNet,
                SkillBotNames.EchoSkillBotDotNet,
                SkillBotNames.EchoSkillBotDotNetV3,
                SkillBotNames.EchoSkillBotJS,
                SkillBotNames.EchoSkillBotJSV3,
                SkillBotNames.EchoSkillBotPython
            };

            var scripts = new List <string> {
                "EchoMultiSkill.json"
            };

            var testCaseBuilder = new TestCaseBuilder();
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };
            var deliveryModes = new List <string>
            {
                DeliveryModes.Normal
            };

            var hostBots = new List <HostBot>
            {
                HostBot.EmptyBotDotNetWebApp,
                HostBot.EmptyBotDotNetFunctions,
                HostBot.EmptyBotJSWebApp,
                HostBot.EmptyBotJSFunctions
            };

            var scripts = new List <string> {
                "EmptyBot.json"
            };

            var testCaseBuilder = new TestCaseBuilder();

            var testCases = testCaseBuilder.BuildTestCases(channelIds, deliveryModes, hostBots, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
Esempio n. 3
0
        public static IEnumerable <object[]> TestCases()
        {
            var clientTypes = new List <ClientType> {
                ClientType.DirectLine
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal
            };

            var hostBots = new List <HostBot>
            {
                HostBot.EchoHostBot
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.EchoSkillBot
            };

            var scripts = new List <string> {
                "ShouldSignIn1.transcript"
            };

            var testCaseBuilder = new TestCaseBuilder();
        private LinksAuthorizationTestCase ConfigureTestCase(Action <TestCaseBuilder> configureTest = null)
        {
            var builder = new TestCaseBuilder();

            configureTest?.Invoke(builder);
            return(builder.BuildAuthorizationServiceTestCase());
        }
        private LinksEvaluatorTestCase ConfigureTestCase(Action <TestCaseBuilder> configureTest)
        {
            var builder = new TestCaseBuilder();

            configureTest?.Invoke(builder);
            return(builder.BuildLinksEvaluatorTestCase());
        }
Esempio n. 6
0
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };

            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.ComposerHostBotDotNet,
                HostBot.WaterfallHostBotDotNet,
                HostBot.WaterfallHostBotJS,
                HostBot.WaterfallHostBotPython,
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,
                SkillBotNames.WaterfallSkillBotJS,
                SkillBotNames.WaterfallSkillBotPython,
                SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "O365.json"
            };

            var testCaseBuilder = new TestCaseBuilder();
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal
            };

            var hostBots = new List <HostBot>
            {
                HostBot.EchoHostBot
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.EchoSkillBot
            };

            var scripts = new List <string> {
                "EchoMultiSkill.json"
            };

            var testCaseBuilder = new TestCaseBuilder();
Esempio n. 8
0
        public void IgnoreWorksForTestCase()
        {
            IgnoredTestCaseFixture fixture = new IgnoredTestCaseFixture();
            Test       test   = TestCaseBuilder.Make(fixture, "CallsIgnore");
            TestResult result = test.Run(NullListener.NULL, null);

            Assert.IsFalse(result.Executed, "TestCase should not run");
            Assert.AreEqual("Ignore me", result.Message);
        }
Esempio n. 9
0
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };

            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.WaterfallHostBotDotNet,

                // TODO: Enable these when the ports to JS, Python and composer are ready
                //HostBotNames.WaterfallHostBotJS,
                //HostBotNames.WaterfallHostBotPython,
                //HostBotNames.ComposerHostBotDotNet
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,

                // TODO: Enable these when the ports to JS, Python and composer are ready
                //SkillBotNames.WaterfallSkillBotJS,
                //SkillBotNames.WaterfallSkillBotPython,
                //SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "BotAction.json",
                "TaskModule.json",
                "SubmitAction.json",
                "Hero.json",
                "Thumbnail.json",
                "Receipt.json",
                "SignIn.json",
                "Carousel.json",
                "List.json",
                "O365.json",
                "Animation.json",
                "Audio.json",
                "Video.json"
            };

            var testCaseBuilder = new TestCaseBuilder();
            var testCases       = testCaseBuilder.BuildTestCases(channelIds, deliverModes, hostBots, targetSkills, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
Esempio n. 10
0
        public void LoadMethodCategories()
        {
            HasCategories fixture = new HasCategories();

            NUnit.Core.TestCase testCase = TestCaseBuilder.Make(fixture, "ATest");
            Assert.IsNotNull(testCase);
            Assert.IsNotNull(testCase.Categories);
            Assert.AreEqual(2, testCase.Categories.Count);
        }
Esempio n. 11
0
        public void CreateIgnoredTestCase()
        {
            MockTestFixture mockTestFixture = new MockTestFixture();

            NUnit.Core.TestCase testCase = TestCaseBuilder.Make(mockTestFixture, "MockTest4");
            Assert.AreEqual(1, testCase.CountTestCases());
            Assert.AreEqual(false, testCase.ShouldRun);
            Assert.AreEqual("ignoring this test method for now", testCase.IgnoreReason);
        }
Esempio n. 12
0
        public void TestMismatchedException()
        {
            MismatchedException me = new MismatchedException();
            Test       test        = TestCaseBuilder.Make(me, "MismatchedExceptionTest");
            TestResult result      = test.Run(NullListener.NULL);

            Assert.IsTrue(result.IsFailure, "MismatchedExceptionTest should have failed");
            Assert.AreEqual("Expected: ArgumentException but was ArgumentOutOfRangeException", result.Message);
        }
Esempio n. 13
0
        public void TestBaseException()
        {
            BaseException be     = new BaseException();
            Test          test   = TestCaseBuilder.Make(be, "BaseExceptionTest");
            TestResult    result = test.Run(NullListener.NULL);

            Assert.IsTrue(result.IsFailure, "BaseExceptionTest should have failed");
            Assert.AreEqual("Expected: ArgumentException but was Exception", result.Message);
        }
        public void SetCorrectTotalTime()
        {
            var testCase = new TestCaseBuilder()
                           .Typical()
                           .Build();

            var timeSpan = RandomDataGenerator.TimeSpanGenerator.GetRandomTimeSpan();

            var sut = CalculateResultService.Calculate(timeSpan, testCase);

            Assert.Equal(timeSpan.TotalMilliseconds, sut.TotalRunTime);
        }
Esempio n. 15
0
        public void RunIgnoredTestCase()
        {
            MockTestFixture mockTestFixture = new MockTestFixture();

            NUnit.Core.TestCase testCase = TestCaseBuilder.Make(mockTestFixture, "MockTest4");
            Assert.AreEqual(1, testCase.CountTestCases());

            TestResult       result     = testCase.Run(NullListener.NULL);
            ResultSummarizer summarizer = new ResultSummarizer(result);

            Assert.AreEqual(0, summarizer.ResultCount);
            Assert.AreEqual(1, summarizer.TestsNotRun);
        }
        public void CalculateAverageRunTime()
        {
            var testCase = new TestCaseBuilder()
                           .Typical()
                           .Build();

            var timeSpan = RandomDataGenerator.TimeSpanGenerator.GetRandomTimeSpan();

            var avgRunTime = timeSpan.TotalMilliseconds / testCase.NumberOfIterationsOfTest;

            var sut = CalculateResultService.Calculate(timeSpan, testCase);

            Assert.Equal(avgRunTime, sut.AverageRunTimePerIteration);
        }
Esempio n. 17
0
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };

            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.WaterfallHostBotDotNet,
                HostBot.WaterfallHostBotJS,
                HostBot.WaterfallHostBotPython,

                // TODO: Enable this when the port to composer is ready
                //HostBot.ComposerHostBotDotNet
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,
                SkillBotNames.WaterfallSkillBotJS,
                SkillBotNames.WaterfallSkillBotPython,

                // TODO: Enable this when the port to composer is ready
                //SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "BotAction.json",
                "TaskModule.json",
                "SubmitAction.json",
                "Hero.json",
                "Thumbnail.json",
                "Receipt.json",
                "SignIn.json",
                "Carousel.json",
                "List.json",
                "O365.json",
                "Animation.json",
                "Audio.json",
                "Video.json"
            };

            var testCaseBuilder = new TestCaseBuilder();
Esempio n. 18
0
        /// <summary>
        /// Method to add test cases to the newly constructed suite.
        /// The default implementation looks at each candidate method
        /// and tries to build a test case from it. This is sufficient
        /// for any fixture that only requires the builtin types of
        /// test cases. A derived builder that supports additional
        /// types will generally override this method in order to
        /// wrap it with code that installs its own test case
        /// builders or decorators and removes them afterward.
        /// </summary>
        /// <param name="fixtureType"></param>
        protected virtual void AddTestCases(Type fixtureType)
        {
            IList methods = GetCandidateTestMethods(fixtureType);

            foreach (MethodInfo method in methods)
            {
                Test test = TestCaseBuilder.BuildFrom(method);

                if (test != null)
                {
                    this.suite.Add(test);
                }
            }
        }
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.WaterfallHostBotDotNet,
                HostBot.WaterfallHostBotJS,
                HostBot.WaterfallHostBotPython,

                // TODO: Enable this when the port to composer is ready
                //HostBot.ComposerHostBotDotNet
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,
                SkillBotNames.WaterfallSkillBotPython,

                // TODO: Enable these when the ports to JS, and composer are ready
                //SkillBotNames.WaterfallSkillBotJS,
                //SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "ProactiveStart.json",
            };

            var testCaseBuilder = new TestCaseBuilder();

            var testCases = testCaseBuilder.BuildTestCases(channelIds, deliverModes, hostBots, targetSkills, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
        public static IEnumerable <object[]> TestCases()
        {
            var clientTypes = new List <ClientType> {
                ClientType.DirectLine
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.WaterfallHostBotDotNet,

                // TODO: Enable these when the ports to JS, Python and composer are ready
                //HostBotNames.WaterfallHostBotJS,
                //HostBotNames.WaterfallHostBotPython,
                //HostBotNames.ComposerHostBotDotNet
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,

                // TODO: Enable these when the ports to JS, Python and composer are ready
                //SkillBotNames.WaterfallSkillBotJS,
                //SkillBotNames.WaterfallSkillBotPython,
                //SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "MessageWithAttachment.json",
            };

            var testCaseBuilder = new TestCaseBuilder();

            var testCases = testCaseBuilder.BuildTestCases(clientTypes, deliverModes, hostBots, targetSkills, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
Esempio n. 21
0
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies,
            };

            var hostBots = new List <HostBot>
            {
                HostBot.ComposerHostBotDotNet,
                HostBot.WaterfallHostBotDotNet,
                HostBot.WaterfallHostBotJS,
                HostBot.WaterfallHostBotPython,
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,
                SkillBotNames.WaterfallSkillBotJS,
                SkillBotNames.WaterfallSkillBotPython,

                // TODO: Enable after fixing issue (The test is failing with timeout after the signIn).
                //SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "SignIn1.json"
            };

            var testCaseBuilder = new TestCaseBuilder();

            var testCases = testCaseBuilder.BuildTestCases(channelIds, deliverModes, hostBots, targetSkills, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
Esempio n. 22
0
        public void RepeatTestFiveTimes()
        {
            NUnit.Core.TestCase baseCase = TestCaseBuilder.Make(new SuccessTest(), "Success");
            Test repeatTest = new RepeatedTest(baseCase, 5);

            int expectedCount = 5 * SuccessTest.Tests;

            Assert.AreEqual(expectedCount, repeatTest.CountTestCases());
            Assert.AreEqual(expectedCount, repeatTest.CountTestCases(EmptyFilter.Empty));

            TestResult result = repeatTest.Run(NullListener.NULL);

            Assert.IsTrue(result.IsSuccess);

            Assert.IsTrue(result is TestSuiteResult);
            TestSuiteResult suiteResult = (TestSuiteResult)result;

            Assert.AreEqual(expectedCount, suiteResult.Results.Count);
        }
        public static IEnumerable <object[]> TestCases()
        {
            var channelIds = new List <string> {
                Channels.Directline
            };

            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies
            };

            var hostBots = new List <HostBot>
            {
                HostBot.ComposerHostBotDotNet,
                HostBot.WaterfallHostBotDotNet,
                HostBot.WaterfallHostBotJS,
                HostBot.WaterfallHostBotPython,
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,
                SkillBotNames.WaterfallSkillBotJS,
                SkillBotNames.WaterfallSkillBotPython,
                SkillBotNames.ComposerSkillBotDotNet
            };

            var scripts = new List <string>
            {
                "Video.json"
            };

            var testCaseBuilder = new TestCaseBuilder();
            var testCases       = testCaseBuilder.BuildTestCases(channelIds, deliverModes, hostBots, targetSkills, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
        public static IEnumerable <object[]> TestCases()
        {
            var clientTypes = new List <ClientType> {
                ClientType.DirectLine
            };
            var deliverModes = new List <string>
            {
                DeliveryModes.Normal,
                DeliveryModes.ExpectReplies,
            };

            var hostBots = new List <HostBot>
            {
                HostBot.WaterfallHostBotDotNet,
                HostBot.WaterfallHostBotJS,
                HostBot.WaterfallHostBotPython
            };

            var targetSkills = new List <string>
            {
                SkillBotNames.WaterfallSkillBotDotNet,
                SkillBotNames.WaterfallSkillBotJS,
                SkillBotNames.WaterfallSkillBotPython
            };

            var scripts = new List <string>
            {
                "Sso.json",
            };

            var testCaseBuilder = new TestCaseBuilder();

            var testCases = testCaseBuilder.BuildTestCases(clientTypes, deliverModes, hostBots, targetSkills, scripts);

            foreach (var testCase in testCases)
            {
                yield return(testCase);
            }
        }
Esempio n. 25
0
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            IParameterInfo[] methodParams = method.GetParameters();
            if (methodParams.Length != 2)
            {
                throw new TargetParameterCountException("JSON data source only supports 1 test methods accepting 1 parameter.");
            }


            var    tests   = new List <TestMethod>();
            string dirPath = GetDirPath(method);

            string[] jsonFiles = Directory.GetFiles(GetDirPath(method), "*.json", SearchOption.AllDirectories);


            foreach (var jsonFile in jsonFiles)
            {
                object[] args = new object[2];
                args[0] = Path.GetFileName(jsonFile).Replace(".json", "").Replace("_", " ");

                string strJson = File.ReadAllText(jsonFile);
                try
                {
                    Type paramType = methodParams[1].ParameterType;
                    var  obj       = JsonConvert.DeserializeObject(strJson, paramType);
                    args[1] = obj;

                    tests.Add(TestCaseBuilder.BuildTestMethod(method, suite, new TestCaseParameters(args)));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Caught Exception: " + ex.ToString());
                }
            }

            return(tests);
        }
Esempio n. 26
0
 static LocalStorageTests()
 {
     TestCaseBuilder.TestCase("LocalStorage", typeof(LocalStorageTests).Prototype);
 }
Esempio n. 27
0
 static FileStreamTests()
 {
     TestCaseBuilder.TestCase("FileStreamTests", typeof(FileStreamTests).Prototype);
 }
Esempio n. 28
0
        public IEnumerable <TestMethod> BuildFrom(IMethodInfo method, Test suite)
        {
            List <TestMethod>         tests        = new List <TestMethod>();
            List <TestCaseParameters> parameterSet = new List <TestCaseParameters>();

            ParameterInfo[] methodParams = method.MethodInfo.GetParameters();

            string filename = GetFilePath(method, "csv");

            if (File.Exists(filename))
            {
                var csv = new CsvHelper.CsvReader(File.OpenText(filename));
                csv.Configuration.Comment          = '#';
                csv.Configuration.IgnoreBlankLines = true;
                csv.Configuration.HasHeaderRecord  = true;
                csv.Configuration.AllowComments    = true;

                while (csv.Read())
                {
                    if (methodParams.Length != csv.CurrentRecord.Length)
                    {
                        throw new TargetParameterCountException("CSV data and method parameters count do not match.");
                    }

                    object[] args = new object[csv.CurrentRecord.Length];
                    for (int i = 0; i < csv.CurrentRecord.Length; i++)
                    {
                        string strValue = csv.CurrentRecord[i].Trim();

                        ParameterInfo paramInfo = methodParams[i];

                        var converter = TypeDescriptor.GetConverter(paramInfo.ParameterType);
                        if (converter != null)
                        {
                            try
                            {
                                var value = converter.ConvertFrom(strValue);
                                args[i] = value;
                            }
                            catch (System.FormatException)
                            {
                                if ("Boolean".Equals(paramInfo.ParameterType))
                                {
                                    // booleans are false by default
                                    args[i] = false;
                                }
                            }
                            catch (Exception e)
                            {
                                throw new TargetException("Unable to convert CSV data to target data type: " + strValue, e);
                            }
                        }
                        else
                        {
                            throw new TargetException("Unable to locate converter for CSV value: " + strValue);
                        }
                    }

                    tests.Add(TestCaseBuilder.BuildTestMethod(method, suite, new TestCaseParameters(args)));
                }
            }
            else
            {
                tests.Add(TestCaseBuilder.BuildTestMethod(method, suite, new TestCaseParameters()));
            }


            return(tests);
        }
Esempio n. 29
0
 public void Init()
 {
     testCase = TestCaseBuilder.Make(fixture, "Method");
 }
Esempio n. 30
0
 public void NoDescription()
 {
     NUnit.Core.TestCase testCase = TestCaseBuilder.Make(fixture, "NoDescriptionMethod");
     Assert.IsNull(testCase.Description);
 }