public void OnPremiseAspectEngineBuilder_VerifyUpdateServiceRegistration(bool automaticUpdates,
                                                                                 bool updateOnStartup, bool fileWatcher, bool expectRegistration)
        {
            // Create the mock data update service
            var updateService = new Mock <IDataUpdateService>();
            // Create the test data file with the specified options
            var dataFile = new DataFileConfiguration()
            {
                AutomaticUpdatesEnabled  = automaticUpdates,
                UpdateOnStartup          = updateOnStartup,
                FileSystemWatcherEnabled = fileWatcher
            };

            // Create the engine using the test builder and passing
            // in the test data file.
            var engine = new TestBuilder(updateService.Object)
                         .AddDataFile(dataFile)
                         .Build();

            if (expectRegistration)
            {
                // Verify the data file was registered with the data update
                // service.
                updateService.Verify(u => u.RegisterDataFile(It.Is <AspectEngineDataFile>(f =>
                                                                                          f.AutomaticUpdatesEnabled == automaticUpdates &&
                                                                                          f.Configuration.UpdateOnStartup == updateOnStartup)), Times.Once());
            }
            else
            {
                // Verify that the data file was not registered with the
                // data update service.
                updateService.Verify(u => u.RegisterDataFile(It.IsAny <AspectEngineDataFile>()), Times.Never());
            }
        }
Ejemplo n.º 2
0
        public void OnPremiseAspectEngineBuilder_VerifyLicenseKeyFailureModes(
            bool automaticUpdates,
            bool updateOnStartup,
            bool fileWatcher,
            bool requireLicenseKey,
            string licenseKey,
            bool expectException)
        {
            // Create the mock data update service
            var updateService = new Mock <IDataUpdateService>();
            // Create the test data file with the specified options
            var dataFile = new DataFileConfiguration()
            {
                AutomaticUpdatesEnabled      = automaticUpdates,
                UpdateOnStartup              = updateOnStartup,
                FileSystemWatcherEnabled     = fileWatcher,
                LicenseKeyRequiredForUpdates = requireLicenseKey,
                DataUpdateLicenseKeys        = new List <string>()
                {
                    licenseKey
                }
            };

            // Create the engine using the supplied test configuration
            Exception thrown = null;

            try
            {
                var engine = new TestBuilder(updateService.Object)
                             .AddDataFile(dataFile)
                             .Build();
            }
            catch (Exception ex)
            {
                thrown = ex;
            }

            if (expectException)
            {
                Assert.IsNotNull(thrown, "Expected an exception to be thrown");
            }
            else
            {
                Assert.IsNull(thrown, "Expected now exceptions to be thrown");
            }
        }