コード例 #1
0
        public void GetProducts_ShouldReturnAllProducts()
        {
            var context = new TestReportAppContext();

            context.Reports.Add(new Report
            {
                Id          = 599,
                Date        = new DateTime(2005, 4, 1),
                TotalAmount = 234,
                BusinessId  = "1",
                SystemId    = "1"
            });
            context.Reports.Add(new Report
            {
                Id          = 699,
                Date        = new DateTime(2005, 3, 1),
                TotalAmount = 567,
                BusinessId  = "2",
                SystemId    = "1"
            });
            context.Reports.Add(new Report
            {
                Id          = 799,
                Date        = new DateTime(2005, 2, 1),
                TotalAmount = 890,
                BusinessId  = "1",
                SystemId    = "2"
            });

            var controller = new ReportsController(context);
            var result     = controller.GetReports() as TestReportDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Local.Count);
        }
コード例 #2
0
        public void GetProduct_ShouldReturnProductWithSameID()
        {
            var context = new TestReportAppContext();

            context.Reports.Add(GetDemoReport());

            var controller = new ReportsController(context);
            var result     = controller.GetReport(999) as OkNegotiatedContentResult <Report>;

            Assert.IsNotNull(result);
            Assert.AreEqual(999, result.Content.Id);
        }
コード例 #3
0
        public void DeleteProduct_ShouldReturnOK()
        {
            var context = new TestReportAppContext();
            var item    = GetDemoReport();

            context.Reports.Add(item);

            var controller = new ReportsController(context);
            var result     = controller.DeleteReport(999) as OkNegotiatedContentResult <Report>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.Id, result.Content.Id);
        }