コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethod1()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "Apple", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                },
                new Products {
                    NumWar = 2, Code = 12, Name = "Peach", Date = new DateTime(2020, 4, 12), Days = 30, Count = 14000, Price = 15
                },
                new Products {
                    NumWar = 2, Code = 13, Name = "Pineapple", Date = new DateTime(2020, 3, 14), Days = 30, Count = 19000, Price = 8
                },
                new Products {
                    NumWar = 1, Code = 14, Name = "Melon", Date = new DateTime(2020, 3, 15), Days = 30, Count = 11000, Price = 20
                }
            };

            createFile(tab);

            rd = new RepDat(testpath);

            var res = rd.GetProd();

            List <Products> res2 = new List <Products>();

            res2.AddRange(res);

            if (!ListsEqual(res2, tab))
            {
                Assert.Fail();
            }
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethod2()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "Apple", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                },
                new Products {
                    NumWar = 2, Code = 11, Name = "Peach", Date = new DateTime(2020, 4, 12), Days = 30, Count = 14000, Price = 15
                }
            };

            createFile(tab);

            rd = new RepDat(testpath);

            bool exceptionOccured = false;

            try
            {
                var res = rd.GetProd();
            }
            catch
            {
                exceptionOccured = true;
            }

            if (!exceptionOccured)
            {
                Assert.Fail();
            }
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethodA()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "Apple", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                },
                new Products {
                    NumWar = 1, Code = 12, Name = "Peach", Date = new DateTime(2020, 4, 12), Days = 30, Count = 14000, Price = 15
                }
            };

            createFile(tab);

            List <Products> expected = tab;

            rd = new RepDat(testpath);

            try
            {
                rd.Del("45");

                List <Products> res = new List <Products>();
                res.AddRange(rd.GetProd());

                if (!ListsEqual(res, expected))
                {
                    Assert.Fail();
                }
            }
            catch
            {
                Assert.Fail();
            }
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethod8()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "Apple", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                }
            };

            createFile(tab);

            rd = new RepDat(testpath);

            bool exceptionOccured = false;

            try
            {
                rd.Add("Ildar", "Ogorodnik", "45", new DateTime(2020, 4, 10).ToString("yyyy.MM.dd"), "LoL", "KeK", "ChebureK");
            }
            catch
            {
                exceptionOccured = true;
            }

            if (!exceptionOccured)
            {
                Assert.Fail();
            }
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethod7()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "Apple", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                }
            };

            createFile(tab);

            rd = new RepDat(testpath);

            List <Products> expected = new List <Products> {
                new Products {
                    NumWar = 1, Code = 12, Name = "Peach", Date = new DateTime(2020, 4, 10), Days = 35, Count = 50, Price = 10
                }
            };

            try
            {
                rd.Add("12", "1", "Peach", new DateTime(2020, 4, 10).ToString("yyyy.MM.dd"), "35", "50", "10");

                List <Products> res = new List <Products>();
                res.AddRange(rd.Search("", "12", "", ""));

                if (!ListsEqual(res, expected))
                {
                    Assert.Fail();
                }
            }
            catch
            {
                Assert.Fail();
            }
        }
コード例 #6
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethod6()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "Apple", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                },
                new Products {
                    NumWar = 1, Code = 12, Name = "Peach", Date = new DateTime(2020, 4, 12), Days = 30, Count = 14000, Price = 15
                }
            };

            createFile(tab);

            rd = new RepDat(testpath);

            List <Products> expected = new List <Products>();

            bool exceptionOccured = false;

            try
            {
                List <Products> res = new List <Products>();

                res.AddRange(rd.Search("", "Ildar", "", ""));
            }
            catch
            {
                exceptionOccured = true;
            }

            if (!exceptionOccured)
            {
                Assert.Fail();
            }
        }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: Darik50/Lab8
        public void TestMethod3()
        {
            List <Products> tab = new List <Products> {
                new Products {
                    NumWar = 1, Code = 11, Name = "", Date = new DateTime(2020, 4, 10), Days = 30, Count = 12000, Price = 10
                }
            };

            createFile(tab);

            rd = new RepDat(testpath);

            try
            {
                var res = rd.GetProd();
            }
            catch
            {
                Assert.Fail();
            }
        }