Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //
                // Populate the list of system printers.
                //
                ddlSystemPrinters.Items.Add(new ListItem(""));
                foreach (String printer in PrinterSettings.InstalledPrinters)
                {
                    ddlSystemPrinters.Items.Add(new ListItem(printer));
                }

                //
                // Populate the list of Arena printers.
                //
                ddlArenaPrinters.Items.Add(new ListItem(""));
                foreach (ComputerSystemPrinter csp in new ComputerSystemPrinterCollection(CurrentArenaContext.Organization.OrganizationID))
                {
                    ddlArenaPrinters.Items.Add(new ListItem(csp.PrinterName));
                }

                //
                // Populate the list of Locations.
                //
                ddlLocations.Items.Add(new ListItem("", "-1"));
                foreach (Location loc in new LocationCollection(CurrentArenaContext.Organization.OrganizationID))
                {
                    ddlLocations.Items.Add(new ListItem(loc.FullName, loc.LocationId.ToString()));
                }

                //
                // Populate the list of Kiosks.
                //
                ddlKiosks.Items.Add(new ListItem(""));
                ComputerSystemCollection csc = new ComputerSystemCollection();
                csc.LoadAllSystems(CurrentArenaContext.Organization.OrganizationID);
                foreach (ComputerSystem comp in csc)
                {
                    if (comp.Kiosk)
                    {
                        ddlKiosks.Items.Add(new ListItem(comp.SystemName, comp.SystemId.ToString()));
                    }
                }

                ReportingService2005 reportingService = new ReportServiceBuilder().GetReportingService();
                foreach (CatalogItem item in reportingService.ListChildren(CurrentOrganization.Settings["ReportServerRoot"] + "/CheckIn", true))
                {
                    if (item.Type == ItemTypeEnum.Report)
                    {
                        ddlRSDirectLabel.Items.Add(new ListItem(item.Name, item.Path));
                        ddlRSFrameworkLabel.Items.Add(new ListItem(item.Name, item.Path));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public async void should_create_a_homestats()
        {
            //arrange
            var model = new HomeStatsModel
            {
                ApplicationCount = 1,
                DeveloperCount   = 2,
                TranslatorCount  = 3,
                KeyCount         = 4,
                TranslationCount = 5
            };

            var userRepository = new Mock <IRepository <User> >();

            userRepository.Setup(x => x.Count(y => y.RoleId != SetLocaleRole.Developer.Value))
            .Returns(2);

            userRepository.Setup(x => x.Count(y => y.RoleId == SetLocaleRole.Translator.Value))
            .Returns(3);

            var wordRepository = new Mock <IRepository <Word> >();

            wordRepository.Setup(x => x.Count(It.IsAny <Expression <Func <Word, bool> > >()))
            .Returns(4);

            wordRepository.Setup(x => x.FindAll(It.IsAny <Expression <Func <Word, bool> > >()))
            .Returns(new List <Word> {
                new Word {
                    TranslationCount = 1
                }, new Word {
                    TranslationCount = 1
                }, new Word {
                    TranslationCount = 1
                }, new Word {
                    TranslationCount = 2
                },
            }.AsQueryable());

            var appRepository = new Mock <IRepository <App> >();

            appRepository.Setup(x => x.Count(It.IsAny <Expression <Func <App, bool> > >()))
            .Returns(1);

            //act
            var sut = new ReportServiceBuilder().WithUserRepository(userRepository.Object)
                      .WithWordRepository(wordRepository.Object)
                      .WithAppRepository(appRepository.Object)
                      .Build();
            var homestats = await sut.GetHomeStats();

            //assert
            Assert.AreEqual(model.ApplicationCount, homestats.ApplicationCount);
            Assert.AreEqual(model.DeveloperCount, homestats.DeveloperCount);
            Assert.AreEqual(model.TranslatorCount, homestats.TranslatorCount);
            Assert.AreEqual(model.KeyCount, homestats.KeyCount);
            Assert.AreEqual(model.TranslationCount, homestats.TranslationCount);

            appRepository.Verify(x => x.Count(It.IsAny <Expression <Func <App, bool> > >()), Times.AtLeastOnce);
            userRepository.Verify(x => x.Count(It.IsAny <Expression <Func <User, bool> > >()), Times.AtLeastOnce);
            wordRepository.Verify(x => x.Count(It.IsAny <Expression <Func <Word, bool> > >()), Times.AtLeastOnce);
            wordRepository.Verify(x => x.FindAll(It.IsAny <Expression <Func <Word, bool> > >()), Times.AtLeastOnce);
        }