Beispiel #1
0
        public async Task TestCallHttpLayerAsync()
        {
            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            var httpLayer = MobileCore.Instance.HttpLayer;

            Assert.IsNotNull(httpLayer, "Mobile Core must return the HTTP layer");
            var request = httpLayer.NewRequest();

            Assert.IsNotNull(request, "NewRequest() must create a request");
            UriBuilder uriBuilder = new UriBuilder(localUrl);

            uriBuilder.Path = GET_TEST_PATH;

            var response = await request.Get(uriBuilder.Uri.ToString()).Execute();

            Assert.NotNull(response);
            Assert.Null(response.Error);
            Assert.IsTrue(response.Successful);
            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual(GET_TEST_BODY, response.Body);
            var jsonObject = JsonObject.Parse(response.Body);

            Assert.AreEqual(HELLO_WORLD, (string)jsonObject["text"]);
            MobileCore.Instance.Destroy();
        }
Beispiel #2
0
 public void TestCoreInitAndDestroy()
 {
     Assert.Catch <InitializationException>(() => MobileCore.Instance.GetType(), "check uninitialized exception before init");
     MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
     Assert.NotNull(MobileCore.Instance, "check core initialized successfuly");
     MobileCore.Instance.Destroy();
     Assert.Catch <InitializationException>(() => MobileCore.Instance.GetType(), "check uninitialized exception after destroy");
 }
        public void TestRegisterService()
        {
            var testInstance = new TestService();

            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            MobileCore.Instance.RegisterService <ITestService>(testInstance);

            var registeredInstance = MobileCore.Instance.GetInstance <ITestService>();

            Assert.NotNull(registeredInstance);
            Assert.AreSame(testInstance, registeredInstance);
        }
        public void TestServiceConfigByType()
        {
            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            var serviceConfigByType = MobileCore.Instance.GetServiceConfigurationByType("dummy");

            MobileCore.Instance.RegisterService <IDummyModule>(new DummyModule(serviceConfigByType[1]));

            var module = MobileCore.Instance.GetInstance <IDummyModule>();

            Assert.IsNotNull(module);
            Assert.AreEqual("dummy", module.Type);
            Assert.AreEqual("Hello world, from anotherdummy!", module.Data1);
            Assert.AreEqual(420, module.Data2);
            Assert.IsFalse(module.Data3);

            MobileCore.Instance.Destroy();
        }
Beispiel #5
0
        public void TestCase()
        {
            var core = new MobileCore();

            Assert.Pass("Test Passes");
        }
 public void Configure(MobileCore core, ServiceConfiguration serviceConfiguration)
 {
 }