Example #1
0
        public void GivenServiceOfTypeExists_Add_Should_ThrowException()
        {
            var services = new Services();

            services.Add(this);

            Assert.Throws <ArgumentException>(() => services.Add(this))
            .Message.Should().Be("service for type 'CommandDotNet.Tests.UnitTests.Framework.ServicesTests' " +
                                 "already exists 'CommandDotNet.Tests.UnitTests.Framework.ServicesTests'");
        }
Example #2
0
        public void GivenServiceOfTypeExists_Add_UsingAnInterface_Should_AddService()
        {
            var methodDef = (NullMethodDef)NullMethodDef.Instance;

            var services = new Services();

            services.Add(methodDef);
            services.Add <IMethodDef>(methodDef);

            var svcs = services.GetAll();

            svcs.Count.Should().Be(2);
            svcs.Should().Contain(kvp => kvp.Key == typeof(IMethodDef));
            svcs.Should().Contain(kvp => kvp.Key == typeof(NullMethodDef));
        }
Example #3
0
        public void GivenServiceOfTypeExists_Add_UsingAnInterface_Should_AddService()
        {
            var operand = new Operand("lala", TypeInfo.Flag, ArgumentArity.ZeroOrOne);

            var services = new Services();

            services.Add(operand);
            services.Add <IArgument>(operand);

            var svcs = services.GetAll();

            svcs.Count.Should().Be(2);
            svcs.Should().Contain(kvp => kvp.Key == typeof(IArgument));
            svcs.Should().Contain(kvp => kvp.Key == typeof(Operand));
        }
Example #4
0
        public SharpmakeUnitTestsProject()
            : base(generateXmlDoc: false)
        {
            Name = "Sharpmake.UnitTests";

            Services.Add("{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}"); // NUnit
        }
Example #5
0
 protected override void Load()
 {
     Title = "Thn Player";
     LibreLancer.Shaders.AllShaders.Compile();
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Viewport = new ViewportManager(this.RenderState);
     Viewport.Push(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     Renderer2D = new Renderer2D(this.RenderState);
     Audio      = new AudioManager(this);
     Sounds     = new SoundManager(Audio);
     Services.Add(Sounds);
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     Services.Add(Renderer2D);
     fontMan = new FontManager();
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
     Typewriter = new Typewriter(this);
     Services.Add(Typewriter);
     Keyboard.KeyDown += KeyboardOnKeyDown;
 }
Example #6
0
        /// <summary>
        /// Initialize the engine. This includes initializing mono addins,
        /// setting the trace level and creating the standard set of services
        /// used in the Engine.
        ///
        /// This interface is not normally called by user code. Programs linking
        /// only to the nunit.engine.api assembly are given a
        /// pre-initialized instance of TestEngine. Programs
        /// that link directly to nunit.engine usually do so
        /// in order to perform custom initialization.
        /// </summary>
        public void Initialize()
        {
            if (InternalTraceLevel != InternalTraceLevel.Off && !InternalTrace.Initialized)
            {
                var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id);
                InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel);
            }

            // If caller added services beforehand, we don't add any
            if (Services.ServiceCount == 0)
            {
                Services.Add(new SettingsService(true));
                Services.Add(new DomainManager());
                Services.Add(new ExtensionService());
                Services.Add(new DriverService());
                Services.Add(new RecentFilesService());
                Services.Add(new ProjectService());
                Services.Add(new RuntimeFrameworkService());
                Services.Add(new DefaultTestRunnerFactory());
                Services.Add(new TestAgency());
                Services.Add(new ResultService());
                Services.Add(new TestFilterService());
            }

            Services.ServiceManager.StartServices();
        }
Example #7
0
        /// <summary>
        /// Adds a Room to the Services list.
        /// </summary>
        /// <param name="room">Room to add.</param>
        /// <returns>
        /// True if one or more Rooms were added.
        /// </returns>
        public bool AddService(Room room)
        {
            var perimeter = room.Perimeter.FitMost(Perimeter);

            if (perimeter == null)
            {
                return(false);
            }
            var fitAmong = new List <Polygon>(OpeningsAsPolygons);

            fitAmong.AddRange(ExclusionsAsPolygons);
            fitAmong.AddRange(ServicesAsPolygons);
            perimeter = perimeter.FitAmong(fitAmong);
            if (perimeter == null)
            {
                return(false);
            }
            Services.Add(new Room(room)
            {
                Elevation = Elevation,
                Height    = height,
                Perimeter = perimeter
            });
            FitCorridors();
            FitRooms();
            return(true);
        }
            /// <summary>
            /// Registers a factory method.
            /// </summary>
            /// <param name="serviceType">Service type.</param>
            /// <param name="factory">Instance factory.</param>
            /// <param name="isScoped">True for scope, false for singletons.</param>
            /// <param name="allowMultipleRegistration">
            /// True to allow the <paramref name="serviceType"/> to already be associated to another mapping.
            /// False to log an error and return false.
            /// </param>
            /// <returns>True on success, false if multiple registration is detected and <paramref name="allowMultipleRegistration"/> is false.</returns>
            public bool Register(Type serviceType, Func <IServiceProvider, object> factory, bool isScoped, bool allowMultipleRegistration)
            {
                ServiceLifetime lt = isScoped ? ServiceLifetime.Scoped : ServiceLifetime.Singleton;

                if (!_registered.TryGetValue(serviceType, out var reg) || allowMultipleRegistration)
                {
                    Monitor.Trace($"Registering factory method for service '{serviceType}' as {lt}.");
                    Services.Add(new ServiceDescriptor(serviceType, factory, lt));
                    if (reg != RegType.None)
                    {
                        _registered.Add(serviceType, allowMultipleRegistration ? RegType.Multiple : RegType.InternalMapping);
                    }
                    return(true);
                }
                if (reg == RegType.PreviouslyRegistered)
                {
                    Monitor.Warn($"Service '{serviceType}' is already registered in ServiceRegister. Skipping {lt} factory method registration.");
                    return(true);
                }
                if (reg == RegType.Multiple)
                {
                    Monitor.Error($"Invalid unique '{serviceType}' registration to a factory method: already registered as a Multiple mapping.");
                }
                else
                {
                    Monitor.Error($"Unable to register mapping of '{serviceType}' to a factory method since the type has already been mapped. ServiceRegister checks that registration occur at most once.");
                }
                return(false);
            }
 bool DoRegisterSingletonInstance(Type serviceType, object implementation, bool isRealObject, bool isMultiple)
 {
     if (!_registered.TryGetValue(serviceType, out var reg) ||
         (isMultiple && (reg == RegType.Multiple || reg == RegType.PreviouslyRegistered)))
     {
         Monitor.Trace($"Registering {(isMultiple ? "multiple" : "unique")} mapping from '{serviceType}' to {(isRealObject ? $"real object '{implementation.GetType().Name}'" : "provided singleton instance")}.");
         Services.Add(new ServiceDescriptor(serviceType, implementation));
         if (reg == RegType.None)
         {
             _registered.Add(serviceType, isMultiple
                                             ? RegType.Multiple
                                             : (isRealObject
                                                 ? RegType.RealObject
                                                 : RegType.InternalMapping));
         }
         return(true);
     }
     if (reg == RegType.PreviouslyRegistered)
     {
         Debug.Assert(!isMultiple);
         Monitor.Warn($"Skipping unique mapping '{serviceType}' to {(isRealObject ? $"real object '{implementation.GetType().Name}'" : "provided singleton instance")} since it is already registered in ServiceCollection.");
         return(true);
     }
     if (reg == RegType.Multiple)
     {
         Monitor.Error($"Invalid unique '{serviceType}' registration to {(isRealObject ? $"real object '{implementation.GetType().Name}'" : "provided singleton instance")}: already registered as a Multiple mapping.");
     }
     else
     {
         Monitor.Error($"Duplicate '{serviceType}' registration in ServiceCollection (singleton instance registration).");
     }
     return(false);
 }
Example #10
0
        public ApplicationViewModel()
        {
            db = new PhotoStudioContext();

            db.Orders.Load();
            db.Clients.Load();
            db.Services.Load();

            db.SaveChanges();

            foreach (Order order in db.Orders.Local.ToList())
            {
                Orders.Add(order);
            }

            foreach (Client client in db.Clients.Local.ToList())
            {
                Clients.Add(client);
            }

            foreach (Service service in db.Services.Local.ToList())
            {
                Services.Add(service);
            }
        }
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);
            Motel = parameters.GetValue <Motel>("MotelDetails");
            Name  = Motel.Name;
            //DONE: Get the current user's position and calculate distance
            GetDistance(Motel);

            foreach (var item in Motel.Images)
            {
                Images.Add(item);
            }
            foreach (var item in Motel.Phones)
            {
                Phones.Add(item);
            }
            foreach (var item in Motel.Services)
            {
                Services.Add(item);
            }

            var analyticsData = new Dictionary <string, string> {
                { "Name", Motel.Name }
            };

            Analytics.TrackEvent("Motel selected", analyticsData);
        }
Example #12
0
        /// <summary>
        /// Initialize the engine. This includes initializing mono addins,
        /// setting the trace level and creating the standard set of services
        /// used in the Engine.
        ///
        /// This interface is not normally called by user code. Programs linking
        /// only to the nunit.engine.api assembly are given a
        /// pre-initialized instance of TestEngine. Programs
        /// that link directly to nunit.engine usually do so
        /// in order to perform custom initialization.
        /// </summary>
        public void Initialize()
        {
            SettingsService settingsService = new SettingsService(true);

            if (InternalTraceLevel == InternalTraceLevel.Default)
            {
                InternalTraceLevel = settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Off);
            }

            if (InternalTraceLevel != InternalTraceLevel.Off)
            {
                var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id);
                InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel);
            }

            Services.Add(settingsService);
            Services.Add(new DomainManager());
#if NUNIT_ENGINE
            Services.Add(new ExtensionService());
#endif
            Services.Add(new DriverService());

#if NUNIT_ENGINE
            Services.Add(new RecentFilesService());
            Services.Add(new ProjectService());
            Services.Add(new RuntimeFrameworkService());
            Services.Add(new DefaultTestRunnerFactory());
            Services.Add(new TestAgency());
            Services.Add(new ResultService());
#else
            Services.Add(new CoreTestRunnerFactory());
#endif

            Services.ServiceManager.StartServices();
        }
        public void AddService(Type serviceType, ServiceCreatorCallback callback, bool promote)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            if (promote && ParentContainer != null)
            {
                ParentContainer.AddService(serviceType, callback, promote);
                return;
            }

            lock (this)
            {
                if (Services.ContainsKey(serviceType))
                {
                    throw new InvalidOperationException(
                              CommonResourceUtil.GetString(Resources.ServiceProvider_ServiceAlreadyExists, serviceType.FullName));
                }
                Services.Add(serviceType, callback);
            }
        }
        public void AddService(Type serviceType, object serviceInstance, bool promote)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            if (serviceInstance == null)
            {
                throw new ArgumentNullException("serviceInstance");
            }
            if (!(serviceInstance is ServiceCreatorCallback)
                &&
                !serviceType.IsInstanceOfType(serviceInstance))
            {
                throw new ArgumentException(
                          CommonResourceUtil.GetString(Resources.ServiceProvider_InvalidServiceInstance, serviceType.FullName, "serviceInstance"));
            }

            if (promote && ParentContainer != null)
            {
                ParentContainer.AddService(serviceType, serviceInstance, promote);
                return;
            }

            lock (this)
            {
                if (Services.ContainsKey(serviceType))
                {
                    throw new InvalidOperationException(
                              CommonResourceUtil.GetString(Resources.ServiceProvider_ServiceAlreadyExists, serviceType.FullName));
                }
                Services.Add(serviceType, serviceInstance);
            }
        }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="port"></param>
        /// <param name="strType">DataSourceType enum + custom online maps</param>
        /// <param name="dataSorucePath"></param>
        /// <param name="disableClientCache"></param>
        /// <param name="displayNoDataTile"></param>
        /// <param name="style"></param>
        /// <param name="tilingSchemePath">Set this parameter only when type is ArcGISDynamicMapService and do not use Google Maps's tiling scheme</param>
        /// <returns>errors or warnings. string.empty if nothing wrong.</returns>
        public static string CreateService(string name, int port, string strType, string dataSorucePath, bool allowMemoryCache, bool disableClientCache, bool displayNoDataTile, VisualStyle style, string tilingSchemePath = null)
        {
            PBSServiceProvider serviceProvider = null;
            string             str;

            if (!PortEntities.ContainsKey(port))
            {
                str = StartServiceHost(port);
                if (str != string.Empty)
                {
                    return(str);
                }
            }
            serviceProvider = PortEntities[port].ServiceProvider;

            if (serviceProvider.Services.ContainsKey(name))
            {
                return("Servicename already exists!");
            }

            PBSService service;

            try
            {
                service = new PBSService(name, dataSorucePath, port, strType, allowMemoryCache, disableClientCache, displayNoDataTile, style, tilingSchemePath);
            }
            catch (Exception e)//in case of reading conf.xml or conf.cdi file error|| reading a sqlite db error
            {
                Utility.Log(LogLevel.Error, null, "Creating New Service(" + name + ") Error!\r\nData Source: " + dataSorucePath + "\r\n\r\n" + e.Message);
                return("Creating New Service(" + name + ") Error!\r\nData Source: " + dataSorucePath + "\r\n\r\n" + e.Message);
            }
            serviceProvider.Services.Add(name, service); //for process http request
            Services.Add(service);                       //for ui binding
            return(string.Empty);
        }
    private string AddRes(string ResID, string Ids, string UserID, string YHMC, string YHZH, string Type)
    {
        string QXResID = "437496957656";//人员权限表ID

        try
        {
            Services          Resource = new Services();
            DataTable         dt       = Resource.GetDataListByResourceID(ResID, false, " and id in (" + Ids + ")").Tables[0];
            List <RecordInfo> infoList = new List <RecordInfo>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RecordInfo info = new RecordInfo();
                info.RecordID      = "0";
                info.ResourceID    = QXResID;
                info.FieldInfoList = GetFieldList(dt.Rows[i], YHZH, YHMC, Type).ToArray();
                infoList.Add(info);
            }
            Resource.Add(UserID, infoList.ToArray());
            return("{\"success\": true}");
        }
        catch (Exception)
        {
            return("{\"success\": false}");
        }
    }
Example #17
0
        /// <summary>
        /// Create and initialize the standard set of services
        /// used in the Engine. This interface is not normally
        /// called by user code. Programs linking only to
        /// only to the nunit.engine.api assembly are given a
        /// pre-initialized instance of TestEngine. Programs
        /// that link directly to nunit.engine usually do so
        /// in order to perform custom initialization.
        /// </summary>
        public void InitializeServices(string workDirectory, InternalTraceLevel traceLevel)
        {
            SettingsService settingsService = new SettingsService("NUnit30Settings.xml", true);

            if (traceLevel == InternalTraceLevel.Default)
            {
                traceLevel = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Off);
            }

            if (traceLevel != InternalTraceLevel.Off)
            {
                var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id);
                InternalTrace.Initialize(Path.Combine(workDirectory, logName), traceLevel);
            }

            Services.Add(settingsService);
            services.Add(new RecentFilesService());
            Services.Add(new DomainManager());
            Services.Add(new ProjectService());
            Services.Add(new RuntimeFrameworkSelector());
            Services.Add(new DefaultTestRunnerFactory());
            Services.Add(new DriverFactory());
            Services.Add(new TestAgency());

            Services.ServiceManager.InitializeServices();
        }
Example #18
0
        public void GivenAServiceIsAdded_Get_ForExistingType_Should_ReturnTheAddedService()
        {
            var services = new Services();

            services.Add(this);
            services.Get <ServicesTests>().Should().Be(this);
        }
        void OnServiceAdded(object obj)
        {
            var service = obj as Service;

            Services.Add(service);
            Services = new ObservableCollection <Service>(Services.OrderBy(s => s.Name));
        }
Example #20
0
        private void ServiceInfo_RetrieveServiceInfoCompleted(object sender, RetrieveServiceInfoEventArgs e)
        {
            if (--_servicesLeft <= 1)
            {
                ArcGisServiceInfo.ServiceInfo.RetrieveServiceInfoCompleted -= ServiceInfo_RetrieveServiceInfoCompleted;
                ArcGisServiceInfo.ServiceInfo.RetrieveFeatureInfoCompleted -= ServiceInfo_RetrieveFeatureInfoCompleted;
                IsDropDownOpen = true;
            }
            try
            {
                if (e.Error != null)
                {
                    ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error pulling arcgis service from server", e.Error);
                    return;
                }

                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    Services.Add(e.ServiceData);
                    NotifyPropertyChanged("ServicesView");
                });
            }
            catch (Exception ex)
            {
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error pulling arcgis services from server", ex);
            }
        }
Example #21
0
        private void ExecuteRemoveMethod(object parameter)
        {
            int index = ReserveServices.IndexOf(SelResService);

            Services.Add(SelResService);
            ReserveServices.Remove(SelResService);
        }
Example #22
0
        public void LoadSessionInfo()
        {
            if (SelectedPayor == null)
            {
                return;
            }

            _currentSession = _esClinicContext.Sessions.Find(SelectedPayor.SessionId);

            TotalCost = _currentSession.TotalCost;

            var services =
                _esClinicContext.Services.Include("ServiceType").ToList().Where(s => s.SessionId == SelectedPayor.SessionId);

            Services.Clear();
            foreach (var service in services)
            {
                Services.Add(service);
            }

            var drugs =
                _esClinicContext.Drugs.Include("Product").ToList().Where(d => d.SessionId == SelectedPayor.SessionId);

            Drugs.Clear();
            foreach (var drug in drugs)
            {
                Drugs.Add(drug);
            }
        }
Example #23
0
        public void ReadServices()
        {
            if (SelectedMachine != null)
            {
                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
                {
                    var services = conn.Table <Service>().Where(m => m.MachineId == SelectedMachine.Id).ToList();

                    Services.Clear();
                    foreach (var service in services)
                    {
                        Services.Add(service);
                    }
                }
            }

            if (SelectedPrintShop != null && SelectedMachine == null)
            {
                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
                {
                    var services = conn.Table <Service>().Where(m => m.PrintShopId == SelectedPrintShop.Id).ToList();

                    Services.Clear();
                    foreach (var service in services)
                    {
                        Services.Add(service);
                    }
                }
            }
        }
        private void AddCancelButtonService()
        {
            var finishDialogueEventRepository = ServiceProvider.GetService <FinishDialogueEventRepository>();
            var service = new FinishDialogueService(finishDialogueEventRepository, dialogueModel);

            Services.Add(service);
        }
        private void AddNpcImageService()
        {
            var iconForDialogueRepository = ServiceProvider.GetService <IconForDialogueRepository>();
            var service = new NpcImageService(iconForDialogueRepository, dialogueModel.IconContainer.Icon);

            Services.Add(service);
        }
Example #26
0
        /// <summary>
        /// Initialize the engine. This includes initializing mono addins,
        /// setting the trace level and creating the standard set of services
        /// used in the Engine.
        ///
        /// This interface is not normally called by user code. Programs linking
        /// only to the nunit.engine.api assembly are given a
        /// pre-initialized instance of TestEngine. Programs
        /// that link directly to nunit.engine usually do so
        /// in order to perform custom initialization.
        /// </summary>
        public void Initialize()
        {
            if (InternalTraceLevel != InternalTraceLevel.Off && !InternalTrace.Initialized)
            {
                var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id);
                InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel);
            }

            // If caller added services beforehand, we don't add any
            if (Services.ServiceCount == 0)
            {
                // Services that depend on other services must be added after their dependencies
                // For example, ResultService uses ExtensionService, so ExtensionService is added
                // later.
                Services.Add(new SettingsService(true));
                Services.Add(new RecentFilesService());
                Services.Add(new TestFilterService());
#if !NETSTANDARD1_6
                Services.Add(new ExtensionService());
                Services.Add(new ProjectService());
#if !NETSTANDARD2_0
                Services.Add(new DomainManager());
                Services.Add(new RuntimeFrameworkService());
                Services.Add(new TestAgency());
#endif
#endif
                Services.Add(new DriverService());
                Services.Add(new ResultService());
                Services.Add(new DefaultTestRunnerFactory());
            }

            Services.ServiceManager.StartServices();
        }
Example #27
0
        protected override void Load()
        {
            Thread.CurrentThread.Name = "FreelancerGame UIThread";
            //Move to stop _TSGetMainThread error on OSX
            MinimumWindowSize = new Point(640, 480);
            SetVSync(Config.VSync);
            new IdentityCamera(this);
            uithread       = Thread.CurrentThread.ManagedThreadId;
            useintromovies = _cfg.IntroMovies;
            FLLog.Info("Platform", Platform.RunningOS.ToString() + (IntPtr.Size == 4 ? " 32-bit" : " 64-bit"));
            FLLog.Info("Available Threads", Environment.ProcessorCount.ToString());
            //Cache
            ResourceManager = new GameResourceManager(this);
            //Init Audio
            FLLog.Info("Audio", "Initialising Audio");
            Audio = new AudioManager(this);
            if (_cfg.MuteMusic)
            {
                Audio.Music.Volume = 0f;
            }
            //Load data
            FLLog.Info("Game", "Loading game data");
            GameData    = new GameDataManager(_cfg.FreelancerPath, ResourceManager);
            IntroMovies = GameData.GetIntroMovies();
            MpvOverride = _cfg.MpvOverride;
            Thread GameDataLoaderThread = new Thread(() =>
            {
                GameData.LoadData();
                Sound = new SoundManager(GameData, Audio);
                FLLog.Info("Game", "Finished loading game data");
                InitialLoadComplete = true;
            });

            GameDataLoaderThread.Name = "GamedataLoader";
            GameDataLoaderThread.Start();
            //
            Renderer2D      = new Renderer2D(RenderState);
            Fonts           = new FontManager(this);
            Billboards      = new Billboards();
            Nebulae         = new NebulaVertices();
            ViewportManager = new ViewportManager(RenderState);
            ViewportManager.Push(0, 0, Width, Height);
            Screenshots = new ScreenshotManager(this);

            Services.Add(Billboards);
            Services.Add(Nebulae);
            Services.Add(ResourceManager);
            Services.Add(Renderer2D);
            Services.Add(Config);
            Services.Add(Fonts);

            if (useintromovies && IntroMovies.Count > 0)
            {
                ChangeState(new IntroMovie(this, 0));
            }
            else
            {
                ChangeState(new LoadingDataState(this));
            }
        }
        public ObjectIntegrationFixture()
        {
            Client             = new HttpClient();
            Client.BaseAddress = new Uri("http://localhost:9090/api/1.0/");

            var mock = new Mock <IHttpClientFactory>();

            mock.CallBase = true;
            mock.Setup(x => x.CreateClient($"unittests-{Common.OBJECT_SERVICE_NAME}")).Returns(Client);

            ClientFactory = mock.Object;
            MongoClient   = new MongoClient("mongodb://localhost:27017");

            MongoBookLogger = new Mock <ILogger <MongoService> >().Object;
            HttpBookLogger  = new Mock <ILogger <HttpObjectService> >().Object;

            MongoBookService = new MongoService(MongoClient, MongoBookLogger);
            HttpBookService  = new HttpObjectService("unittests", ClientFactory, HttpBookLogger);

            Services.Add(MongoBookService);
            Services.Add(HttpBookService);

            foreach (var service in Services)
            {
                service.DeleteCollectionAsync(DB_NAME, GetCollectionName(service));
            }
        }
Example #29
0
        public void GivenAServiceIsAdded_GetWithType_ForExistingType_Should_ReturnTheAddedService()
        {
            var services = new Services();

            services.Add(this);
            services.GetOrDefault(this.GetType()).Should().Be(this);
        }
Example #30
0
        public void GivenAServiceIsAdded_Get_ForNonExistingType_Should_ReturnNull()
        {
            var services = new Services();

            services.Add(this);
            services.GetOrDefault(services.GetType()).Should().BeNull();
        }
Example #31
0
        public HttpResponseMessage Root()
        {
            Services services = new Services();
            TileMapServiceMetadata metadata = new TileMapServiceMetadata();
            metadata.title = "Tile Map Service";
            metadata.version = "1.0.0";
            metadata.href = Url.Link("TMSService", new { Version = "1.0.0" });
            services.Add(metadata);

            return Request.CreateResponse(HttpStatusCode.OK, services, new XmlMediaTypeFormatter() { UseXmlSerializer = true });
        }
        /// <summary>
        /// Finds services for a device.
        /// </summary>
        /// <param name="device">The device to get the services for.</param>
        /// <param name="interfaceGuid">The network guid for any new devices if available.</param>
        /// <param name="serviceType">The service type for the services to search for.</param>
        /// <returns>The services found.</returns>
        public static Services FindServices(this IUPnPDevice device, Guid interfaceGuid, string serviceType)
        {
            Services lsServices = new Services();

            foreach (IUPnPService lsService in device.Services)
                if (lsService.ServiceTypeIdentifier == serviceType)
                    lsServices.Add(new Service(device, interfaceGuid, lsService));

            foreach (IUPnPDevice ldDevice in device.Children)
                lsServices.AddRange(ldDevice.FindServices(interfaceGuid, serviceType));

            return lsServices;
        }