Ejemplo n.º 1
0
        public void ShouldUpdateColumnsWithUniqueValuesWhenGetSuccessfulResult()
        {
            var validPath = @"somefile.xls";
            var data      = new[]
            {
                new Dictionary <string, double> {
                    { "one", 1.23 }, { "two", 45 }
                },
                new Dictionary <string, double> {
                    { "one", 1.0 }, { "two", 128.7 }
                },
                new Dictionary <string, double> {
                    { "one", 3.14 }, { "two", 0.123 }
                }
            };
            var result = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(validPath).Returns(result);
            var expectedColumns = new[]
            {
                new DataColumnViewModel("one")
                {
                    SelectionType = SelectionType.NotSelected
                },
                new DataColumnViewModel("two")
                {
                    SelectionType = SelectionType.NotSelected
                }
            };

            ViewModel.LoadDataCommand.Execute(validPath);

            ViewModel.Columns.ShouldBeEquivalentTo(expectedColumns);
        }
Ejemplo n.º 2
0
        public void ShouldRaisePropertyChangedForErrorMessageWhenFailedResultChangedToSuccessful()
        {
            var validPath = @"data.xlsx";
            var data      = new[]
            {
                new Dictionary <string, double> {
                    { "five", 0 }, { "six", 0 }
                }
            };
            var successfulResult = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(validPath).Returns(successfulResult);

            var invalidPath  = @"notexisted.file";
            var failedResult = DataResult.CreateFailed("File not found");

            FakeProvider.GetFrom(invalidPath).Returns(failedResult);

            ViewModel.LoadDataCommand.Execute(invalidPath);

            ViewModel.MonitorEvents();

            ViewModel.LoadDataCommand.Execute(validPath);

            ViewModel.ShouldRaisePropertyChangeFor(viewModel => viewModel.ErrorMessage);
        }
Ejemplo n.º 3
0
        public void ShouldResetReportData()
        {
            var inputData = new ScatterInputData
            {
                Data = new[]
                {
                    new Dictionary <string, double> {
                        { "seven", 0.00052 }, { "eight", 1.000012 }, { "nine", 1.1 }
                    },
                    new Dictionary <string, double> {
                        { "seven", 0.0000010101 }, { "eight", 0.12456 }, { "nine", 1.2 }
                    }
                },
                AbscissaColumnName = "seven",
                OrdinateColumnName = "eight"
            };

            var dataResult = DataResult.CreateSuccessful(inputData.Data);

            FakeProvider.GetFrom(null).ReturnsForAnyArgs(dataResult);

            var dummyReportData = GenerateDummyReportData();

            FakeScatterReportCalculator.Calculate(null).ReturnsForAnyArgs(dummyReportData);

            ViewModel.LoadDataCommand.Execute("dummy.path");
            var(abscissaColumn, ordinateColumn) = SelectColumnsForReport("seven", "nine");
            ViewModel.GenerateReportDataCommand.Execute(null);

            ViewModel.LoadDataCommand.Execute("dummy2.path");

            ViewModel.Report.ShouldBeEquivalentTo(ScatterReportData.Empty);
        }
        public void SetUp()
        {
            var data = new[]
            {
                new Dictionary <string, double>
                {
                    { "one", 0.00052 },
                    { "two", 2.17 },
                    { "three", 3.14 },
                    { "four", 4.42 },
                    { "five", 1.5 },
                    { "six", 16 },
                    { "seven", 71.51 },
                    { "eight", 64.12 },
                    { "nine", 29.00900 },
                    { "ten", 1.00010010001 },
                }
            };

            var dataResult = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(null).ReturnsForAnyArgs(dataResult);

            ViewModel.LoadDataCommand.Execute("dummy.path");
        }
Ejemplo n.º 5
0
        public void ShouldPassCorrectInputValuesToTheCalculatorWhenSuccessfulyLoadData()
        {
            ScatterInputData actualInputData = null;
            var expectedInputData            = new ScatterInputData
            {
                Data = new[]
                {
                    new Dictionary <string, double> {
                        { "seven", 0.00052 }, { "eight", 1.000012 }, { "nine", 1.1 }
                    },
                    new Dictionary <string, double> {
                        { "seven", 0.0000010101 }, { "eight", 0.12456 }, { "nine", 1.2 }
                    }
                },
                AbscissaColumnName = "seven",
                OrdinateColumnName = "eight"
            };

            var dataResult = DataResult.CreateSuccessful(expectedInputData.Data);

            FakeProvider.GetFrom(null).ReturnsForAnyArgs(dataResult);

            var dummyReportData = new ScatterReportData(Enumerable.Empty <ScatterPoint>(), new ScatterLine(new ScatterPoint(), new ScatterPoint()));

            FakeScatterReportCalculator.Calculate(Arg.Do <ScatterInputData>(input => actualInputData = input)).ReturnsForAnyArgs(dummyReportData);

            ViewModel.LoadDataCommand.Execute("dummy.path");
            SelectColumnsForReport("seven", "eight");

            ViewModel.GenerateReportDataCommand.Execute(null);

            actualInputData.ShouldBeEquivalentTo(expectedInputData);
        }
Ejemplo n.º 6
0
        public void ShouldClearColumnsWhenGetFailedResult()
        {
            var path         = @"notExistedFile.xls";
            var failedResult = DataResult.CreateFailed("File not found");

            FakeProvider.GetFrom(path).Returns(failedResult);

            ViewModel.LoadDataCommand.Execute(path);

            ViewModel.Columns.Should().BeEmpty();
        }
Ejemplo n.º 7
0
        public void ShouldRaiseOnPropertyChangedForErrorMessageWhenGetFailedResult()
        {
            var path         = @"file.txt";
            var failedResult = DataResult.CreateFailed("Provider doesn not support this type of file");

            FakeProvider.GetFrom(path).Returns(failedResult);
            ViewModel.MonitorEvents();

            ViewModel.LoadDataCommand.Execute(path);

            ViewModel.ShouldRaisePropertyChangeFor(viewModel => viewModel.ErrorMessage);
        }
Ejemplo n.º 8
0
        private void ConfigureDataForCanExecuteTests()
        {
            var data = new[]
            {
                new Dictionary <string, double> {
                    { "one", 0.00052 }, { "two", 1.000012 }, { "three", 1.1 }
                }
            };

            var dataResult = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(null).ReturnsForAnyArgs(dataResult);

            ViewModel.LoadDataCommand.Execute("dummy.path");
        }
Ejemplo n.º 9
0
        public void ShouldRaisePropertyChangedForAbscissaColumnName()
        {
            var validPath = @"anotherFile.xls";
            var data      = new[]
            {
                new Dictionary <string, double> {
                    { "three", 1.23 }, { "five", 4.785 }, { "two", 42 }
                }
            };
            var result = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(validPath).Returns(result);
            ViewModel.MonitorEvents();

            ViewModel.LoadDataCommand.Execute(validPath);

            ViewModel.ShouldRaisePropertyChangeFor(viewmodel => viewmodel.AbscissaColumnName);
        }
Ejemplo n.º 10
0
        public void ShouldRaiseCanExecuteForGenerateReportDataCommand()
        {
            var validPath = @"anotherFile.xls";
            var data      = new[]
            {
                new Dictionary <string, double> {
                    { "three", 1.23 }, { "five", 4.785 }, { "two", 42 }
                }
            };
            var result = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(validPath).Returns(result);
            ViewModel.GenerateReportDataCommand.MonitorEvents();

            ViewModel.LoadDataCommand.Execute(validPath);

            ViewModel.GenerateReportDataCommand.ShouldRaise("CanExecuteChanged");
        }
Ejemplo n.º 11
0
        public void ShouldClearErrorMessageWhenGetSuccessfulResult()
        {
            var validPath = @"file.csv";
            var data      = new[]
            {
                new Dictionary <string, double> {
                    { "three", 0.2 }, { "four", -45.34 }
                },
                new Dictionary <string, double> {
                    { "three", 0 }, { "four", 1.55 }
                }
            };
            var result = DataResult.CreateSuccessful(data);

            FakeProvider.GetFrom(validPath).Returns(result);

            ViewModel.LoadDataCommand.Execute(validPath);

            ViewModel.ErrorMessage.Should().BeNull();
        }