コード例 #1
0
        public StatisticsDto CalculateStatistics()
        {
            var statistics = new StatisticsDto();

            foreach (var element in StatisticsSequence)
            {
                if (element.C45Errors == element.C50Errors)
                {
                    statistics.Equal++;
                }
                else if (element.C45Errors < element.C50Errors)
                {
                    statistics.C45Better++;
                }
                else
                {
                    statistics.C50Better++;
                }
            }

            return statistics;
        }
コード例 #2
0
        public void AddToRepository(StatisticsDto statistics)
        {
            if (string.IsNullOrWhiteSpace(BluePrint))
            {
                throw new BllException("BluePrint not set.");
            }

            if (statistics == null)
            {
                throw new BllException("StatisticsDto can not be null.");
            }

            var statisticsResult = new StatisticsResult
            {
                BluePrint = BluePrint,
                C45Better = statistics.C45Better,
                C50Better = statistics.C50Better,
                Equal = statistics.Equal
            };

            _statisticsResultsRepository.Add(statisticsResult);
        }
コード例 #3
0
        public void AddToRepository_EverythingIsSetUp_ShouldFormCorrectObjectForRepository()
        {
            StatisticsResult result = null;
            var statistics = new StatisticsDto
            {
                C45Better = 10,
                C50Better = 20,
                Equal = 5
            };

            _statisticsResultsRepositoryMock
                .Setup(x => x.Add(It.IsAny<StatisticsResult>()))
                .Callback<StatisticsResult>(x => result = x);

            _service.BluePrint = "Test";

            _service.AddToRepository(statistics);

            Assert.IsNotNull(result);
            Assert.AreEqual("Test", result.BluePrint);
            Assert.AreEqual(10, result.C45Better);
            Assert.AreEqual(20, result.C50Better);
            Assert.AreEqual(5, result.Equal);
        }