Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("請輸入查詢分組單位以幾筆為一組:");
            var groupCount = Console.ReadLine();

            Console.WriteLine("請輸入查詢分組總和的欄位:");
            var groupColumn = Console.ReadLine();

            GroupSumService gsService = new GroupSumService(GetObjectType());
            var             result    = gsService.GetSummary(Int32.Parse(groupCount), groupColumn);
        }
Esempio n. 2
0
        public void 測試Expection_2筆一組_取SellPrice總和_輸入不存在的欄位_使用FluentAssertions()
        {
            //arrange
            var target      = new GroupSumService(new HomeworkDao());
            var groupCount  = 9;
            var groupColumn = "badasfda";
            var expected    = new List <int>()
            {
                225, 61
            };

            Action act = () => target.GetSummary(groupCount, groupColumn);

            act.ShouldThrow <NullReferenceException>();
        }
Esempio n. 3
0
        public void 測試Expection_2筆一組_取SellPrice總和_輸入不存在的欄位()
        {
            //arrange
            var target      = new GroupSumService(new HomeworkDao());
            var groupCount  = 9;
            var groupColumn = "dasfasdf";
            var expected    = new List <int>()
            {
                225, 61
            };

            //act
            var actual = target.GetSummary(groupCount, groupColumn);

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void 測試_2筆一組_取SellPrice總和_使用自訂類別()
        {
            //arrange
            var target      = new GroupSumService(new ExtraDao());
            var groupCount  = 9;
            var groupColumn = "col3";
            var expected    = new List <int>()
            {
                225, 61
            };

            //act
            var actual = target.GetSummary(groupCount, groupColumn);

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public void 測試_4筆一組_取Revenue總和()
        {
            //arrange
            var target      = new GroupSumService(new HomeworkDao());
            var groupCount  = 4;
            var groupColumn = "revenue";
            var expected    = new List <int>()
            {
                50, 66, 60
            };

            //act
            var actual = target.GetSummary(groupCount, groupColumn);

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public void 測試_3筆一組_取Cost總和()
        {
            //arrange
            var target      = new GroupSumService(new HomeworkDao());
            var groupCount  = 3;
            var groupColumn = "cost";
            var expected    = new List <int>()
            {
                6, 15, 24, 21
            };

            //act
            var actual = target.GetSummary(groupCount, groupColumn);

            //assert
            CollectionAssert.AreEqual(expected, actual);
        }