コード例 #1
0
        public void Execute_WhenExecuteApiTesterWithSimpleMethodWithNullable_ShouldGetCorrectNumberOfResults()
        {
            var myApi   = new MyApi();
            var results = breakIt.Execute(myApi, nameof(myApi.CallApiEnums), new List <object> {
                MyApi.SomeEnum.FirstValue, MyApi.SomeEnum.SecondValue
            });

            Assert.AreEqual(5, results.Count);
        }
コード例 #2
0
        public void Execute_WhenExecuteApiTesterWithSimpleMethod_ShouldGetCorrectNumberOfResults()
        {
            var myApi   = new MyApi();
            var results = breakIt.Execute(myApi, nameof(myApi.CallApi), new List <object> {
                1, "someName"
            });

            Assert.AreEqual(4, results.Count);
        }
コード例 #3
0
        public void Execute_WhenExecuteApiTesterWithMethodWithList_ShouldGetCorrectNumberOfResults()
        {
            var myApi  = new MyApi();
            var result = breakIt.Execute(myApi, nameof(myApi.CallApiList), new List <object> {
                new List <string> {
                    "Buu"
                }
            });

            Assert.AreEqual(2, result.Count);
        }
コード例 #4
0
        private static Task RunClassStaticSampleAsync()
        {
            Console.WriteLine("Please, please enter some text and I will calulate the lenght.");

            var txt = Console.ReadLine();

            var len = MyApi.GetLength(txt);

            Console.WriteLine($"The length of the text is: {len}");

            return(Task.CompletedTask);
        }
コード例 #5
0
        public void Execute_WhenExecuteApiTesterWithMethodThatShowException_ShouldSeeExceptionInResult()
        {
            var myApi        = new MyApi();
            var memoryLogger = new MemoryTestValueLogger();
            var apiTester    = new BreakIt(memoryLogger);
            var result       = apiTester.Execute(myApi, nameof(myApi.CallApiWithException), new List <object> {
                1, "someName"
            });

            Assert.IsNotNull(result[0].Exception);
            Assert.AreEqual("Something is wrong", result[0].Exception.Message);
        }
コード例 #6
0
        public void Execute_WhenExecuteApiTesterWithMethodThatShowException_ShouldSeeExceptionInLog()
        {
            var myApi        = new MyApi();
            var memoryLogger = new MemoryTestValueLogger();
            var apiTester    = new BreakIt(memoryLogger);

            apiTester.Execute(myApi, nameof(myApi.CallApiWithException), new List <object> {
                1, "someName"
            });

            StringAssert.Contains("Something is wrong", memoryLogger.LogLines[0]);
        }
コード例 #7
0
        public void Execute_WhenExecuteApiTesterWithMethodWithListThatContainsComplexClass_ShouldGetCorrectNumberOfResults()
        {
            var myApi  = new MyApi();
            var result = breakIt.Execute(myApi, nameof(myApi.CallApiListComplex), new List <object> {
                new List <SomeComplexType> {
                    new SomeComplexType {
                        Name = "test", Number = 1
                    }
                }
            });

            Assert.AreEqual(4, result.Count);
        }
コード例 #8
0
        public void Execute_WhenExecuteApiTesterWithMethodWithDictionaryThatContainsComplexClass_ShouldGetCorrectNumberOfResults()
        {
            var myApi  = new MyApi();
            var result = breakIt.Execute(myApi, nameof(myApi.CallApiDictionaryComplex), new List <object> {
                new Dictionary <string, SomeComplexType> {
                    ["Bu"] = new SomeComplexType {
                        Name = "test", Number = 1
                    }, ["Tjo"] = new SomeComplexType {
                        Name = "test", Number = 1
                    }
                }
            });

            Assert.AreEqual(8, result.Count);
        }
コード例 #9
0
        public void Execute_WhenExecuteApiTesterWithMethodThatReturnValue_ShouldBeAbleToValidateAndHaveCorrectValueInResult()
        {
            var myApi        = new MyApi();
            var memoryLogger = new MemoryTestValueLogger();
            var options      = new BreakItOptions();

            options.Validation = ((testValue, o1, exception) => (int)o1 == 1);

            var apiTester = new BreakIt(memoryLogger);
            var result    = apiTester.Execute(myApi, nameof(myApi.CallApiWithValidation), new List <object> {
                1, "someName"
            }, options);

            Assert.IsFalse(result[0].IsSuccess);
            Assert.IsTrue(result[1].IsSuccess);
        }
コード例 #10
0
        public void Execute_WhenExecuteApiTesterWithMethodThatReturnValue_ShouldBeAbleToValidateAndHaveCorrectValueInLog()
        {
            var myApi        = new MyApi();
            var memoryLogger = new MemoryTestValueLogger();
            var options      = new BreakItOptions();

            options.Validation = (testValue, o1, exception) => (int)o1 == 1;

            var apiTester = new BreakIt(memoryLogger);

            apiTester.Execute(myApi, nameof(myApi.CallApiWithValidation), new List <object> {
                1, "someName"
            }, options);

            StringAssert.Contains("NOT OK", memoryLogger.LogLines[0]);
        }
コード例 #11
0
        private static Task RunClassInstanceSampleAsync()
        {
            while (true)
            {
                Console.WriteLine("Please, please arg 1:");
                var arg1 = Console.ReadLine();

                if (arg1 == "exit")
                {
                    break;
                }

                Console.WriteLine("Please, please arg 2:");
                var arg2 = Console.ReadLine();

                if (arg2 == "exit")
                {
                    break;
                }


                try
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;

                    MyApi apiInstance = new MyApi();

                    double res = apiInstance.Divide(int.Parse(arg1), int.Parse(arg2));

                    Console.WriteLine($"Result of {arg1}/{arg2} = {res}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Your input is not the best. Pls. try again :)");
                }
                finally
                {
                    Console.ResetColor();
                }
            }



            return(Task.CompletedTask);
        }
コード例 #12
0
ファイル: MainPage.xaml.cs プロジェクト: navizv/Spb-Metro-X
        public MainPage()
        {
            this.InitializeComponent();
            MyApi api = new MyApi(this);

            webView1.AddWebAllowedObject("API", api);
            webView1.Source = new Uri("ms-appx-web:///Assets/default.html");
            resetFields();
            clearButton.Click += async(o, i) =>
            {
                await webView1.InvokeScriptAsync("reset_selection", null);

                resetFields();
            };
            buildPopup();
            toField.Tapped             += ToField_Tapped;
            fromField.Tapped           += ToField_Tapped;
            Window.Current.SizeChanged += (a, b) => { centerPopup(); };
        }
コード例 #13
0
        public void ShouldConsiderConstraintsWhenCallingInvoke()
        {
            var engine = new Engine(options =>
            {
                options.TimeoutInterval(TimeSpan.FromMilliseconds(100));
            });
            var myApi = new MyApi();

            engine.SetValue("myApi", myApi);
            engine.Execute("myApi.addEventListener('DataReceived', (data) => { myApi.log(data) })");

            var dataReceivedCallbacks = myApi.Callbacks.Where(kvp => kvp.Key == "DataReceived");

            foreach (var callback in dataReceivedCallbacks)
            {
                engine.Invoke(callback.Value, "Data Received #1");
                Thread.Sleep(101);
                engine.Invoke(callback.Value, "Data Received #2");
            }
        }
コード例 #14
0
ファイル: MyThingTest.cs プロジェクト: syndicate72/CITesting
 public MyThing(MyApi api)
 {
     this.api = api;
 }
コード例 #15
0
ファイル: MyApiClient.cs プロジェクト: paulyoung/Bug31772
 public MyApiClient()
 {
     Api = new MyApi();
 }