コード例 #1
0
        public void TestChartAsync_NormallyExcuted_ShouldReturnTrue()
        {
            var stub = new StubIChartUtil(MockBehavior.Strict);

            viewModel.ChartDao = stub;
            int except1 = 0, except2 = 0;

            stub.ChartLengendAsync(async(sites) =>
            {
                ObservableCollection <ChartLengend> s = new ObservableCollection <ChartLengend>();
                await Task.CompletedTask;
                except1 = sites.Count;
                return(s);
            }, Times.Once);
            stub.CacuChartAsync(async(sites, logs) =>
            {
                ObservableCollection <ObservableCollection <Chart1> > data1 = new ObservableCollection <ObservableCollection <Chart1> >();
                ObservableCollection <BarChartData> data2 = new ObservableCollection <BarChartData>();
                except2 = sites.Count + logs.Count;
                await Task.CompletedTask;
                return(new Tuple <ObservableCollection <ObservableCollection <Chart1> >, ObservableCollection <BarChartData> >(data1, data2));
            }, Times.Once);

            Assert.IsTrue(viewModel.ChartAsync(Sites, Logs).Result);
            Assert.AreEqual(5, except1);
            Assert.AreEqual(10, except2);
        }
コード例 #2
0
        public void TestAcceptClickAsync_NumberOfSiteLE5_ShouldReturnTrue()
        {
            Assert.IsTrue(viewModel.InitAsync().Result);
            var stub = new StubIChartUtil(MockBehavior.Strict);

            viewModel.ChartDao = stub;
            for (int i = 0; i < 4; i++)
            {
                viewModel.Infos.SiteInfoCompleted.Add(new AddSiteInfo()
                {
                    IsSelected = true
                });
            }
            stub.SetLineChartLengendAsync(async(sites) =>
            {
                ObservableCollection <LineChartLengend> s = new ObservableCollection <LineChartLengend>();
                await Task.CompletedTask;
                return(s);
            }, Times.Twice);
            stub.StatisticsSiteRequestResultAsync(async(sites, logs) =>
            {
                ObservableCollection <ObservableCollection <LineChartData> > data1 = new ObservableCollection <ObservableCollection <LineChartData> >();
                ObservableCollection <BarChartData> data2 = new ObservableCollection <BarChartData>();
                await Task.CompletedTask;
                return(new Tuple <ObservableCollection <ObservableCollection <LineChartData> >, ObservableCollection <BarChartData> >(data1, data2));
            }, Times.Twice);
            //less
            Assert.IsTrue(viewModel.AcceptClickAsync().Result);
            //equal
            viewModel.Infos.SiteInfoCompleted.Add(new AddSiteInfo()
            {
                IsSelected = true
            });
            Assert.IsTrue(viewModel.AcceptClickAsync().Result);
        }