コード例 #1
0
        public void Test_CreateDashboard_Should_Create_When_ValidDataAdded()
        {
            // Arrange
            Mock <IDashboardRepository> dashboardRep = new Mock <IDashboardRepository>();

            dashboardRep.Setup(x => x.Add(It.IsAny <Dashboard>())).Callback <Dashboard>((x) => _dashboards.Add(x));
            Mock <IUserDashboardRelRepository> userDashRelRep = new Mock <IUserDashboardRelRepository>();

            userDashRelRep.Setup(x => x.Add(It.IsAny <UserDashboardRel>())).Callback <UserDashboardRel>((z) => _dashUserRel.Add(z));
            Mock <IReportRepository> reportRep = new Mock <IReportRepository>();

            reportRep.Setup(x => x.Get(It.IsAny <string>())).Returns <string>((z) => _reports.SingleOrDefault(x => x.ReportGUID.Equals(z)));
            Mock <IReportDashboardRelRepository> repDashRel = new Mock <IReportDashboardRelRepository>();

            repDashRel.Setup(x => x.Add(It.IsAny <ReportDashboardRel>())).Callback <ReportDashboardRel>(z => _reportDashRel.Add(z));
            // Act
            DashboardManager manager  = new DashboardManager(dashboardRep.Object, repDashRel.Object, reportRep.Object, userDashRelRep.Object);
            string           dashGUID = manager.CreateDashboard(new CreateDashboardDto
            {
                Name    = "testing",
                Reports = new List <szakdoga.Models.Dtos.QueryDtos.ReportDashboardRelDto>
                {
                    new szakdoga.Models.Dtos.QueryDtos.ReportDashboardRelDto
                    {
                        Position = "1", ReportGUID = "Valid"
                    }
                }
            },
                                                                _users[0]);

            ReportDashboardRel report = _reportDashRel.FirstOrDefault(x => x.Report.ReportGUID == "Valid" && x.Dashboard.Name == "testing");

            // Assert
            Assert.AreEqual(true, report != null);
        }
コード例 #2
0
 public void Update(ReportDashboardRel entity)
 {
     if (entity != null)
     {
         _context.ReportDashboardRel.Update(entity);
         _context.SaveChanges();
     }
 }