public void GenerateSchemaClassesTest()
        {
            var generator = new GoogleSchemaGenerator(new List<ISchemaDecorator>(), "Fish.Chips");
            var mockService = new MockService();

            var mockSchema = new MockSchema();
            mockSchema.Id = "Fish";
            mockSchema.Name = "Fish";
            mockSchema.SchemaDetails = new JsonSchema();
            mockService.Schemas.Add("Fish", mockSchema);

            mockSchema = new MockSchema();
            mockSchema.Id = "Chips";
            mockSchema.Name = "Chips";
            mockSchema.SchemaDetails = new JsonSchema();
            mockService.Schemas.Add("Chips", mockSchema);

            CodeNamespace result = generator.GenerateSchemaClasses(mockService);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Types.Count);
            List<string> classNames = new List<string>(2);
            classNames.Add(result.Types[0].Name);
            classNames.Add(result.Types[1].Name);

            Assert.That(classNames.Contains("Fish"));
            Assert.That(classNames.Contains("Chips"));
        }
Exemple #2
0
 public void Setup()
 {
     _actualService = new MockService();
     _marshalledOnServer = Marshal.Get(_actualService);
     _marshalledOnClient = Marshal.Get<IMockService>((Func<string, object[], object>)
         ((name, args) => _marshalledOnServer.Invoke(name, args)));
 }
 public void GenerateSchemaClassesParameterValidationTest()
 {
     var generator = new GoogleSchemaGenerator(new List<ISchemaDecorator>(), "Fish.Chips");
     Assert.Throws(typeof(ArgumentNullException), () => generator.GenerateSchemaClasses(null));
     var mockService = new MockService();
     Assert.DoesNotThrow(() => generator.GenerateSchemaClasses(mockService));
 }
 public void InvokeCallsMethod()
 {
     MockService service = new MockService();
     TypeMethodImpl impl = GetImpl("Sub");
     impl.Invoke(service, null);
     Assert.AreSame(impl.Method, service.LastCalledMethod);
 }
 public void BeginInvokeWithCallback()
 {
     MockService service = new MockService();
     TypeMethodImpl impl = GetImpl("Sub");
     bool[] called = new bool[1];
     impl.BeginInvoke(service, null, new AsyncCallback(OnInvoked), called);
     Assert.IsTrue(called[0]);
 }
        public void ConstructorTest()
        {
            var service = new MockService();

            var exception = new GoogleApiException(service, "Test");
            Assert.IsInstanceOf<Exception>(exception);
            Assert.That(exception.Service, Is.EqualTo(service));
            Assert.That(exception.ToString(), Contains.Substring(service.Name));
        }
Exemple #7
0
        public void Register_ThrowsException_WithMultipleRegistrationOfSameService()
        {
            MockService service = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service);

            Assert.ThrowsException<InvalidOperationException>(() => lifetimeManager.Register(service));
        }
        internal static void Register(int portNumber, MockService startedScenario)
        {
            lock (s_Scenarios)
            {
                if (s_Scenarios.ContainsKey(portNumber))
                    throw new InvalidOperationException("port in use");

                s_Scenarios[portNumber] = startedScenario;
            }
        }
Exemple #9
0
        public void Unregister_ThrowsException_IfServiceIsNotRegistered()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service1);

            Assert.ThrowsException<InvalidOperationException>(() => lifetimeManager.Unregister(service2));
        }
        public void verify_can_handle_AtomEntry_response_for_create_entry()
        {
            var mock = new Mock<ISDataResponse>(MockBehavior.Strict);
            mock.SetupGet(r => r.Content).Returns(new AtomEntry());
            mock.SetupGet(r => r.ETag).Returns(String.Empty);

            var service = new MockService(mock);
            var result = service.CreateEntry(new SDataServiceOperationRequest(service) { OperationName = "computePrice" }, new AtomEntry());
            Expect(result, Is.InstanceOf<AtomEntry>());
        }
        public async Task Activate_ReturnsTrueIfAnyHandlerReturnTrue()
        {
            MockService service1 = new MockService(Task.FromResult(false));
            MockService service2 = new MockService(Task.FromResult(true));

            ActivationManager activationManager = CreateActivationManager(services: new[] { service1, service2 });

            bool result = await activationManager.Activate(new MockActivatedEventArgs());

            Assert.Equal(true, result);
        }
        public void Register_ThrowsException_WithMultipleRegistrationOfSameService()
        {
            MockService service = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service);

            var e = Assert.Throws<InvalidOperationException>(() => lifetimeManager.Register(service));

            Assert.Equal("Cannot register the service as it is already registered.", e.Message);
        }
Exemple #13
0
        public void RegistedServices_ReceiveResumingEvent()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();

            TestableLifetimeManager lifetimeManager = CreateLifetimeManager(new[] { service1, service2 });

            lifetimeManager.Resume();

            CollectionAssert.AreEqual(new string[] { "OnResuming" }, service1.LifetimeEventCalls);
            CollectionAssert.AreEqual(new string[] { "OnResuming" }, service2.LifetimeEventCalls);
        }
        public void Unregister_ThrowsException_IfServiceIsNotRegistered()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();
            LifetimeManager lifetimeManager = new LifetimeManager();

            lifetimeManager.Register(service1);

            var e = Assert.Throws<InvalidOperationException>(() => lifetimeManager.Unregister(service2));

            Assert.Equal("Cannot unregister the service as it is not currently registered.", e.Message);
        }
        public void RegistedServices_ReceiveSuspendingEvent()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();

            TestableLifetimeManager lifetimeManager = CreateLifetimeManager(new[] { service1, service2 });

            lifetimeManager.Suspend(new MockSuspendingEventArgs());

            Assert.Equal<string>(new string[] { "OnSuspending" }, service1.LifetimeEventCalls);
            Assert.Equal<string>(new string[] { "OnSuspending" }, service2.LifetimeEventCalls);
        }
Exemple #16
0
        public void TestServiceException()
        {
            User user = new User();
            Service service = new MockService();
            user.Service = service;
            Terminal terminal = new Terminal();
            terminal.Technology = NetWorkType.UMTS;
            user.Terminal = terminal;

            List<NetWorkType> res = UserAssist.JudgeUserSupportNetwork(user);
           
        }
        public async Task Activate_RegistedServicesReceiveActivateEvents()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();

            ActivationManager activationManager = CreateActivationManager(services: new[] { service1, service2 });

            await activationManager.Activate(new MockActivatedEventArgs());

            Assert.Equal(new[] { "Activating", "Activate", "Activated" }, service1.LifetimeEventCalls.Select(e => e.Item1).ToArray());
            Assert.Equal(new[] { "Activating", "Activate", "Activated" }, service2.LifetimeEventCalls.Select(e => e.Item1).ToArray());
        }
        public async Task Activate_RegistedServicesReceiveActivatedEventArgs()
        {
            MockService service1 = new MockService();
            MockService service2 = new MockService();

            ActivationManager activationManager = CreateActivationManager(services: new[] { service1, service2 });

            MockActivatedEventArgs eventArgs = new MockActivatedEventArgs();
            await activationManager.Activate(eventArgs);

            Assert.Equal<IActivatedEventArgs>(new[] { eventArgs, eventArgs, eventArgs }, service1.LifetimeEventCalls.Select(e => e.Item2).ToArray());
            Assert.Equal<IActivatedEventArgs>(new[] { eventArgs, eventArgs, eventArgs }, service2.LifetimeEventCalls.Select(e => e.Item2).ToArray());
        }
Exemple #19
0
        public void TestPolyMode()
        {
            User  user = new User();
            Service service = new MockService();
            service.Technology = (NetWorkType.GSM | NetWorkType.UMTS);
            Terminal terminal = new Terminal();
            terminal.Technology = (NetWorkType.GSM | NetWorkType.UMTS);
            user.Service = service;
            user.Terminal = terminal;

            List<NetWorkType> res = UserAssist.JudgeUserSupportNetwork(user);
            Assert.AreEqual(2, res.Count);
        }
Exemple #20
0
 public void BeginInvokeWithoutCallback()
 {
     MockService service = new MockService();
     TypeMethodImpl impl = GetImpl("Sub");
     object state = new object();
     IAsyncResult ar = impl.BeginInvoke(service, null, null, state);
     Assert.IsNotNull(ar);
     Assert.IsTrue(ar.CompletedSynchronously);
     Assert.IsTrue(ar.IsCompleted);
     Assert.AreSame(state, ar.AsyncState);
     Assert.IsNotNull(ar.AsyncWaitHandle);
     Assert.AreSame(impl.Method, service.LastCalledMethod);
 }
Exemple #21
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var portNumber =
                Int32.Parse(
                    (string)((IList<IDictionary<string, object>>)appBuilder.Properties["host.Addresses"])[0]["port"]);

            _service = MockServiceRepository.GetServiceMockForPort(portNumber);

            if (Debugger.IsAttached) appBuilder.Use(typeof (LoggingMiddleware));

            appBuilder.Use(typeof (BufferedBodyMiddleware));

            appBuilder.Run(Invoke);
        }
        public void Activate_DoesNotRaiseActivatedEventUntilAllHandlersComplete()
        {
            MockService service1 = new MockService();
            TaskCompletionSource<bool> service2Completion = new TaskCompletionSource<bool>();
            MockService service2 = new MockService(service2Completion.Task);

            ActivationManager activationManager = CreateActivationManager(services: new[] { service1, service2 });

            // NB: Do not await this as will only complete when all tasks complete!
            Task<bool> result = activationManager.Activate(new MockActivatedEventArgs());

            Assert.Equal(false, result.IsCompleted);
            Assert.Equal(new[] { "Activating", "Activate" }, service1.LifetimeEventCalls.Select(e => e.Item1).ToArray());
            Assert.Equal(new[] { "Activating", "Activate" }, service2.LifetimeEventCalls.Select(e => e.Item1).ToArray());
        }
        public void CompileTest()
        {
            var decorator = new ScopeEnumDecorator();
            var service = new MockService();
            var decl = new CodeTypeDeclaration("TestClass");

            // Test with a simple scope enumeration
            service.Scopes.Add("a", new Scope { ID = "a", Description = "description A" });
            service.Scopes.Add("b", new Scope { ID = "b", Description = "description B" });

            Scope complex = new Scope() { ID = "https://example.com/test/auth123" };
            service.Scopes.Add(complex.ID, complex);

            decorator.DecorateClass(service, decl);
            CheckCompile(decl, false, "Failed To Compile ScopeEnumDecorator");
        }
        public void When_packageUrl_is_inaccessible_it_throws_an_exception_with_a_useful_message()
        {
            var packageAgent = new PackageAgent();

            var packageName = Any.Word() + ".nupkg";

            using (var mockService = new MockService()
                .OnRequest(r => r.Path.ToString() == "/" + packageName)
                .RespondWith(r => r.StatusCode = 403))
            {
                var packageUri = new Uri(mockService.GetBaseAddress() + packageName);

                Action getPackageAction = () => packageAgent.GetPackage(packageUri).Wait();

                getPackageAction
                    .ShouldThrow<HttpRequestException>("Because the packageUrl cannot be null")
                    .WithMessage("Response status code does not indicate success: 403 (Forbidden).");
            }
        }
        public void DecorateClassTest()
        {
            var decorator = new ScopeEnumDecorator();
            var service = new MockService();
            var decl = new CodeTypeDeclaration();

            // Confirm that no enumeration is added if 0 scopes are available.
            decorator.DecorateClass(service, decl);
            Assert.AreEqual(0, decl.Members.Count);

            // Confirm that an enumeration is added if scopes are available.
            service.Scopes.Add("a", new Scope { ID = "a", Description = "description A" });
            service.Scopes.Add("b", new Scope { ID = "b", Description = "description B" });
            decorator.DecorateClass(service, decl);
            Assert.AreEqual(1, decl.Members.Count);
            Assert.IsInstanceOf<CodeTypeDeclaration>(decl.Members[0]);

            CodeTypeDeclaration enumType = decl.Members[0] as CodeTypeDeclaration;
            Assert.IsNotNull(enumType);
            Assert.IsTrue(enumType.IsEnum);
            Assert.AreEqual(ScopeEnumDecorator.EnumName, enumType.Name);
        }
        public async void When_packageUrl_is_valid_Then_it_returns_the_package()
        {
            var packageAgent = new PackageAgent();

            var packageName = Any.Word() + ".nupkg";

            Package package;

            using (var mockService = new MockService()
                .OnRequest(r => r.Path.ToString() == "/" + packageName)
                .RespondWith(r => r.WriteAsync(Resources.Microsoft_Bcl_1_1_8)))
            {
                var packageUri = new Uri(mockService.GetBaseAddress() + packageName);

                package = await packageAgent.GetPackage(packageUri);
            }

            package.Should().NotBeNull("Because it should be retrieved");

            package.GetParts()
                .Should()
                .HaveCount(92, "Because that is how many package parts are in the Microsoft.Bcl.1.1.8 package");
        }
        public void AddIsMethodResultTest()
        {
            var dic = new Dictionary<JsonSchema, SchemaImplementationDetails>();
            var schema = new JsonSchema();
            var service = new MockService();
            service.Schemas.Add("TestSchema", new MockSchema() { SchemaDetails = schema });
            var method = new MockMethod() { ResponseType = "TestSchema"};

            // Test parameter validation:
            Assert.Throws<ArgumentNullException>(
                () => ImplementationDetailsGenerator.AddIsMethodResult(null, service, method));
            Assert.Throws<ArgumentNullException>(
                () => ImplementationDetailsGenerator.AddIsMethodResult(dic, null, method));
            Assert.Throws<ArgumentNullException>(
                () => ImplementationDetailsGenerator.AddIsMethodResult(dic, service, (IMethod)null));

            // Test single add:
            ImplementationDetailsGenerator.AddIsMethodResult(dic, service, method);
            Assert.AreEqual(dic.Count, 1);

            var implDetails = dic[schema];
            Assert.IsTrue(implDetails.IsMethodResult);
        }
        public void ThrowTest()
        {
            var service = new MockService();

            Assert.Throws <GoogleApiException>(() => { throw new GoogleApiException(service, "Test"); });
        }
        public void When_it_changes_a_namespace_then_responses_odata_type_is_translated_to_new_namespace()
        {
            var oldNamespace = _model.EntityContainer.Namespace;

            var namespacePrefix = Any.CSharpIdentifier();

            var namespaceRename = Any.CSharpIdentifier();

            var newNamespace = new OdcmNamespace(namespacePrefix + "." + namespaceRename);

            var namespaceMap = new Dictionary <string, string> {
                { oldNamespace.Name, namespaceRename }
            };

            var entityClasses = oldNamespace.Classes.OfType <OdcmEntityClass>().ToList();

            var baseClass = entityClasses.Where(c => c.Base == null).RandomElement();

            entityClasses.Remove(baseClass);

            baseClass.IsAbstract = true;

            var derivedClass = entityClasses.RandomElement();

            entityClasses.Remove(derivedClass);

            derivedClass.Base = baseClass;

            entityClasses.RandomElement().Base = baseClass;

            var proxy = GetProxyWithChangedNamespaces(namespacePrefix, namespaceMap);

            var entityArtifacts = GetEntityArtifactsFromNewNamespace(derivedClass, newNamespace, proxy, oldNamespace);

            var responseObject = entityArtifacts.Class.GetSampleJObject(derivedClass.GetSampleKeyArguments().Concat(baseClass.GetSampleKeyArguments()).ToArray());

            var responseOdataType = String.Format("#{0}.{1}", oldNamespace.Name, derivedClass.Name);

            var singletonPath = baseClass.GetDefaultSingletonPath();

            using (var mockService = new MockService(true)
                   )
            {
                mockService
                .OnRequest(c => c.Request.Method == "GET" && c.Request.Path.Value == singletonPath)
                .RespondWith(
                    (c, b) =>
                {
                    c.Response.StatusCode = 200;
                    c.Response.WithDefaultODataHeaders();
                    c.Response.WithODataEntityResponseBody(mockService.GetBaseAddress(),
                                                           baseClass.GetDefaultEntitySetName(), responseObject, new JProperty("@odata.type", new JValue(responseOdataType)));
                });

                var fetcher = mockService
                              .CreateContainer(proxy.GetClass(newNamespace.Name, _model.EntityContainer.Name))
                              .GetPropertyValue <RestShallowObjectFetcher>(baseClass.GetDefaultSingletonName());

                var task = fetcher.ExecuteAsync();

                var result = task.GetPropertyValue <EntityBase>("Result");
            }
        }
 public static ResponseBuilder OnDeleteLinkRequest(this MockService mockService, string entityPath)
 {
     return(mockService
            .OnRequest(c => c.Request.Method == "DELETE" && c.Request.Path.Value == entityPath + "/$ref"));
 }
 public SystemController(MockService mockService)
 {
     this.mockService = mockService;
 }
 /// <summary>
 /// Creates a simple GET request for a "TestMethod".
 /// </summary>
 private Request GetSimpleRequest()
 {
     var service = new MockService() { BaseUri = new Uri("http://example.com")};
     var request =
         (Request)
         Request.CreateRequest(
             service, new MockMethod { HttpMethod = "GET", Name = "TestMethod", RestPath = "" });
     request.WithParameters("");
     return request;
 }
Exemple #33
0
        public async Task UpdateGetShouldCallGetAsyncOnce()
        {
            await ControllerUnderTest.Update(Guid.Empty);

            MockService.Verify(mock => mock.GetAsync(It.IsAny <Guid>()), Times.Once);
        }
        public ActionResult Index()
        {
            var service = new MockService();

            return(View(service.GetAccount()));
        }
 public static ResponseBuilder OnPostEntityRequest(this MockService mockService, string entitySetPath)
 {
     return(mockService
            .OnRequest(c => c.Request.Method == "POST" && c.Request.Path.Value == entitySetPath));
 }
Exemple #36
0
        public JsonResult GetData()
        {
            var service = new MockService();

            return(Json(service.GetAccount(), JsonRequestBehavior.AllowGet));
        }
 public void Create()
 {
     mockService = new MockService("John Doe", "LogoApp");
     viewModel   = new ProjectCreatorViewModel(mockService);
 }
Exemple #38
0
        public void Desktop(string agent)
        {
            var resolver = MockService.DeviceService(agent);

            Assert.Equal(Device.Desktop, resolver.Type);
        }
Exemple #39
0
        public void Safari(string agent)
        {
            var resolver = MockService.Browser(agent);

            Assert.Equal(Browser.Safari, resolver.Name);
        }
 public static ResponseBuilder OnGetEntityCountRequest(this MockService mockService, string entitySetPath)
 {
     return(mockService
            .OnRequest(c => c.Request.Method == "GET" && c.Request.Path.Value == entitySetPath + "/$count"));
 }
Exemple #41
0
        public void Firefox(string agent)
        {
            var resolver = MockService.Browser(agent);

            Assert.Equal(Browser.Firefox, resolver.Name);
        }
        public void Init()
        {
            schemaModel = new SchemaModel
            {
                DataSchemaID = 1,
                Description  = "Blah blah",
                Name         = "Name",
                Status       = TemplateStatus.Draft,
                Version      = 1
            };

            dSchemaDraft = new DataSchema
            {
                ID        = 1,
                Name      = "Draft",
                CreatedBy = 1,
                CreatedAt = today,
                Status    = (int)TemplateStatus.Draft
            };

            dSchemaPublished = new DataSchema
            {
                ID          = 2,
                Name        = "Published",
                CreatedAt   = today,
                CreatedBy   = 1,
                PublishedAt = today
            };

            dSchemaRetracted = new DataSchema
            {
                ID        = 3,
                Name      = "Retracted",
                CreatedAt = today,
                Status    = (int)TemplateStatus.Retracted
            };

            schemaFile = new SchemaFile
            {
                DataSchemaID = dSchemaDraft.ID,
                CreatedBy    = 1,
                FileFormat   = ".xml",
                ID           = 1
            };
            consumerOrganization = new Organization
            {
                ID = 1
            };
            providerOrganization = new Organization
            {
                ID = 2
            };
            providerApplication = new Application
            {
                ID             = 1,
                OrganizationID = providerOrganization.ID
            };
            consumerApplication = new Application
            {
                ID             = 2,
                OrganizationID = consumerOrganization.ID
            };
            providerLicense = new OrganizationLicense
            {
                ID            = 1,
                ApplicationID = providerApplication.ID
            };
            consumerLicense = new OrganizationLicense
            {
                ID            = 2,
                ApplicationID = consumerApplication.ID
            };
            licenseMatch = new LicenseMatch
            {
                ID = 1,
                ConsumerLicenseID = consumerLicense.ID,
                ProviderLicenseID = providerLicense.ID
            };
            endpoint = new ProviderEndpoint
            {
                ApplicationId = providerApplication.ID,
                DataSchemaID  = dSchemaPublished.ID,
                IsActive      = true
            };

            var file = new Mock <HttpPostedFileBase>();

            file.Setup(i => i.InputStream).Returns(new MemoryStream());
            file.Setup(i => i.FileName).Returns("file.xml");
            schemaModel.UploadFile = file.Object;
            var mock = new Mock <UrlHelper>();
            // Setup file
            var fileMock = new Mock <HttpPostedFileBase>();

            fileMock.Setup(x => x.FileName).Returns("file1.xml");
            var context = new Mock <ControllerContext>();

            context.Setup(m => m.HttpContext.Request.Files.Count).Returns(1);
            context.Setup(m => m.HttpContext.Request.Files[0]).Returns(fileMock.Object);
            context.Setup(m => m.HttpContext.Request.Url).Returns(new Uri("http://test.com"));
            sysAdmin = new User
            {
                ID         = 1,
                IsActive   = true,
                Email      = "*****@*****.**",
                IsSysAdmin = true
            };

            // Setup Services
            metaDataService            = new Mock <IDataSchemaService>();
            fileService                = new Mock <ISchemaFileService>();
            organizationService        = new Mock <IOrganizationService>();
            userService                = new Mock <IUserService>();
            notificationService        = new Mock <INotificationService>();
            endpointService            = new Mock <IProviderEndpointService>();
            applicationService         = new Mock <IApplicationsService>();
            configurationService       = new Mock <IConfigurationService>();
            organizationLicenseService = new Mock <IOrganizationLicenseService>();

            userService.Setup(u => u.Get(sysAdmin.ID)).Returns(sysAdmin);
            configurationService.SetupProperty(p => p.ManageSchemasPageSize, 5);
            // Setup organization service
            organizationService.Setup(m => m.Get(consumerOrganization.ID)).Returns(consumerOrganization);
            organizationService.Setup(m => m.Get(providerOrganization.ID)).Returns(providerOrganization);
            // Setup application service
            applicationService.Setup(m => m.Get(providerApplication.ID)).Returns(providerApplication);
            applicationService.Setup(m => m.Get(consumerApplication.ID)).Returns(consumerApplication);
            // Setup endpoint service
            endpointService.Setup(m => m.Get(endpoint.ID)).Returns(endpoint);
            // Setup organization licenses
            organizationLicenseService.Setup(i => i.Get(It.IsAny <Expression <Func <OrganizationLicense, bool> > >()))
            .Returns(new List <OrganizationLicense>());
            organizationLicenseService.Setup(m => m.GetAllProviderLicensesForMonth(It.IsAny <DateTime>()))
            .Returns(new List <OrganizationLicense> {
                providerLicense
            });
            organizationLicenseService.Setup(m => m.Get(consumerLicense.ID)).Returns(consumerLicense);
            // Schema file service
            fileService.Setup(m => m.Add(It.IsAny <SchemaFile>())).Returns(true);
            fileService.Setup(m => m.Update(It.IsAny <SchemaFile>())).Returns(true);
            fileService.Setup(m => m.Get(schemaFile.ID)).Returns(schemaFile);
            fileService.Setup(m => m.Get(It.IsAny <Expression <Func <SchemaFile, bool> > >()))
            .Returns(new List <SchemaFile> {
                schemaFile
            });
            // Dataschema service
            metaDataService.Setup(m => m.GetAllSchemas(1, false)).Returns(new List <DataSchema> {
                dSchemaDraft
            });
            metaDataService.Setup(m => m.Add(It.IsAny <DataSchema>())).Returns(true);
            metaDataService.Setup(m => m.Update(It.IsAny <DataSchema>())).Returns(true);
            metaDataService.Setup(m => m.Get(dSchemaDraft.ID)).Returns(dSchemaDraft);
            metaDataService.Setup(m => m.Get(dSchemaPublished.ID)).Returns(dSchemaPublished);
            metaDataService.Setup(m => m.Get(dSchemaRetracted.ID)).Returns(dSchemaRetracted);

            // License matches
            var mService = new MockService <LicenseMatch>();

            matchesService = new LicenseMatchesService(mService);
            matchesService.Add(licenseMatch);

            // Setup controller
            controller = new SchemasController(metaDataService.Object, fileService.Object, userService.Object,
                                               organizationService.Object, endpointService.Object, applicationService.Object, notificationService.Object, organizationLicenseService.Object, matchesService, configurationService.Object)
            {
                ControllerContext = context.Object,
                LoggedInUser      = new LoggedInUserDetails(sysAdmin),
                Url = mock.Object
            };
        }
Exemple #43
0
        public void Servo(Engine engine, string agent)
        {
            var resolver = MockService.EngineService(agent);

            Assert.Equal(engine, resolver.Name);
        }
 public static ResponseBuilder OnPostEntityPropertyRequest(this MockService mockService, string entityPath,
                                                           string propertyName)
 {
     return(mockService
            .OnRequest(c => c.Request.Method == "POST" && c.Request.Path.Value == entityPath + "/" + propertyName));
 }
Exemple #45
0
        public void MobilePrefix(string agent)
        {
            var resolver = MockService.DeviceService(agent);

            Assert.Equal(Device.Mobile, resolver.Type);
        }
 public HomeController()
 {
     var mockService = new MockService();
 }
Exemple #47
0
        public void Others(string agent)
        {
            var resolver = MockService.Browser(agent);

            Assert.Equal(Browser.Others, resolver.Name);
        }
 public static MockService SetupPostEntityPropertyChanges(this MockService mockService, EntityArtifacts targetEntity, IEnumerable <Tuple <string, object> > keyValues, OdcmProperty property)
 {
     return(mockService
            .OnPostEntityRequest(targetEntity.Class.GetDefaultEntityPropertyPath(property, keyValues))
            .RespondWithODataOk());
 }
Exemple #49
0
 /// <summary>
 /// Sets the mock service.
 /// </summary>
 /// <param name="mockService">The mock service.</param>
 private void SetMockService <T>(IMock <T> mockService) where T : class
 {
     Service.TryAddSingleton <T>(mockService.Object);
     MockService.Add(typeof(T), mockService);
 }
Exemple #50
0
 internal MockServiceInfo(DreamHostInfo hostInfo, string path, MockService service)
 {
     AtLocalMachine = Plug.New(hostInfo.Host.LocalMachineUri.At(path));
     AtLocalHost    = Plug.New(hostInfo.LocalHost.At(path));
     Service        = service;
 }
 public void Inject(MockService mockService) =>
 InjectionCalled = true;
Exemple #52
0
 internal MockServiceInfo(DreamHostInfo hostInfo, string path, MockService service)
 {
     AtLocalMachine = Plug.New(hostInfo.Host.LocalMachineUri.At(path));
     AtLocalHost = Plug.New(hostInfo.LocalHost.At(path));
     Service = service;
 }
        public void BuildRequestUrlWithDefaultedParameters()
        {
            var parameterDefinitions = new Dictionary<string, IParameter>();
            parameterDefinitions.Add(
                "required", new MockParameter { Name = "required", IsRequired = true, ParameterType = "query" });
            parameterDefinitions.Add(
                "optionalWithValue",
                new MockParameter
                    {
                        Name = "optionalWithValue",
                        IsRequired = false,
                        ParameterType = "query",
                        DefaultValue = "DoesNotDisplay"
                    });
            parameterDefinitions.Add(
                "optionalWithNull",
                new MockParameter
                    { Name = "optionalWithNull", IsRequired = false, ParameterType = "query", DefaultValue = "c" });
            parameterDefinitions.Add(
                "optionalWithEmpty",
                new MockParameter
                    { Name = "optionalWithEmpty", IsRequired = false, ParameterType = "query", DefaultValue = "d" });
            parameterDefinitions.Add(
                "optionalNotPressent",
                new MockParameter
                    {
                        Name = "optionalNotPressent",
                        IsRequired = false,
                        ParameterType = "query",
                        DefaultValue = "DoesNotDisplay"
                    });
            var parameterValues = new SortedDictionary<string, string>();
            parameterValues.Add("required", "a");
            parameterValues.Add("optionalWithValue", "b");
            parameterValues.Add("optionalWithNull", null);
            parameterValues.Add("optionalWithEmpty", "");

            var service = new MockService();
            var request =
                (Request)
                Request.CreateRequest(
                    service,
                    new MockMethod
                        {
                            HttpMethod = "GET",
                            Name = "TestMethod",
                            RestPath = "https://example.com",
                            Parameters = parameterDefinitions
                        });

            request.WithParameters(parameterValues);
            var url = request.BuildRequest().RequestUri;

            Assert.AreEqual(
                "https://example.com/?alt=json&optionalWithEmpty=d&" +
                "optionalWithNull=c&optionalWithValue=b&required=a", url.AbsoluteUri);
        }
Exemple #54
0
 public void SetUp()
 {
     materialEditor = new MockMaterialEditorViewModel();
     mockService    = new MockService("Test", "Test");
     viewModel      = new MaterialEditorViewModel(mockService);
 }
 public void Inject(MockService mock) => AncestorInjected = true;
Exemple #56
0
        public void Tablet(string agent)
        {
            var resolver = MockService.DeviceService(agent);

            Assert.Equal(Device.Tablet, resolver.Type);
        }
        [InlineData("0.0", "")]                                                                                                                                                         // Other
        public void GetVersion(string version, string agent)
        {
            var resolver = MockService.Platform(agent);

            Assert.Equal(new Version(version), resolver.Version);
        }
Exemple #58
0
 public void Setup()
 {
     _s3ClientMock = null;
     _mockService  = MockService.CreateMockServiceWithPrivateStorage(_hostInfo);
     _storageRoot  = _mockService.Service.Storage.Uri.LastSegment;
 }