コード例 #1
0
        public void WhenIPostAResource_ThenICanGetItViaHttpAndSignalRClientsAreNotified()
        {
            var application = new Data.Entities.Application {
                ApplicationId = 1, Name = "TestApplication1"
            };

            _createApplication.Execute(application);

            var locale   = new GetAllLocales().Execute()[10].ToContract();
            var resource = GetResourceModel(locale, "Test", "Test", "Test", application.ToContract());

            Post(resource);

            var response = _browser.Get("/api/resource", with =>
            {
                with.Header("Accept", "application/json");
                with.Query("application", application.Name);
                with.Query("resourceSet", resource.ResourceSet);
                with.Query("resourceKey", resource.ResourceKey);
                with.Query("locale", resource.Locale.IsoCode);
            });

            var result = JsonConvert.DeserializeObject <Resource>(response.Body.AsString());

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(result.ApplicationId, Is.EqualTo(application.ApplicationId));
            Assert.That(result.ResourceKey, Is.EqualTo(resource.ResourceKey));
            Assert.That(result.ResourceSet, Is.EqualTo(resource.ResourceSet));
            Assert.That(result.Locale.IsoCode, Is.EqualTo(resource.Locale.IsoCode));

            _bootstrapper
            .Resolve <IMockClient>()
            .Received()
            .addResource(Arg.Any <dynamic>());
        }
コード例 #2
0
        public void WhenIPutAResource_ThenTheResourceIsUpdatedAndSignalRClientsAreNotified()
        {
            var application = new Data.Entities.Application {
                ApplicationId = 1, Name = "TestApplication1"
            };

            _createApplication.Execute(application);

            var locale        = new GetAllLocales().Execute()[0].ToContract();
            var resourceModel = GetResourceModel(locale, "Test", "Test", "Test", application.ToContract());

            Post(resourceModel);

            var resource = _getResource.Execute(application.Name, "Test", "Test", locale.IsoCode);

            resourceModel       = resource.ToContract();
            resourceModel.Value = "Ponies";

            Put(resourceModel);

            resource = _getResource.Execute(application.Name, "Test", "Test", locale.IsoCode);
            Assert.That(resource.Value, Is.EqualTo("Ponies"));

            _bootstrapper
            .Resolve <IMockClient>()
            .Received()
            .updateResource(Arg.Any <dynamic>());
        }
コード例 #3
0
        public void WhenIGenerateBingResourcesForAGivenLocale_ThenICanGetItViaHttpAndSignalRClientsAreNotified()
        {
            var application = new Data.Entities.Application {
                ApplicationId = 1, Name = "TestApplication1"
            };

            _createApplication.Execute(application);

            var locale                 = new GetAllLocales().Execute().Single(l => l.IsoCode == "en-GB").ToContract();
            var targetLocale           = new GetAllLocales().Execute().Single(l => l.IsoCode == "de-DE").ToContract();
            var resource               = GetResourceModel(locale, "Test", "Test", "Hello World", application.ToContract());
            var generateResourcesModel = GetGenerateResourcesModel(application.ApplicationId, locale.LocaleId, targetLocale.LocaleId, "bing");

            Post(resource);
            Post(generateResourcesModel);

            var response = _browser.Get("/api/resource", with =>
            {
                with.Header("Accept", "application/json");
                with.Query("application", application.Name);
                with.Query("resourceSet", resource.ResourceSet);
                with.Query("resourceKey", resource.ResourceKey);
                with.Query("locale", targetLocale.IsoCode);
            });

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));

            var result = JsonConvert.DeserializeObject <Resource>(response.Body.AsString());

            Assert.That(result.ApplicationId, Is.EqualTo(application.ApplicationId));
            Assert.That(result.ResourceKey, Is.EqualTo(resource.ResourceKey));
            Assert.That(result.ResourceSet, Is.EqualTo(resource.ResourceSet));
            Assert.That(result.Locale.IsoCode, Is.EqualTo(targetLocale.IsoCode));
            Assert.That(result.Value, Is.EqualTo("Hallo Welt"));

            _bootstrapper
            .Resolve <IMockClient>()
            .Received()
            .addResource(Arg.Any <dynamic>());
        }
コード例 #4
0
        public void WhenIDeleteAResource_ThenTheResourceIsRemovedAndSignalRClientsAreNotified()
        {
            var application = new Data.Entities.Application {
                ApplicationId = 1, Name = "TestApplication1"
            };

            _createApplication.Execute(application);

            var locale        = new GetAllLocales().Execute()[0].ToContract();
            var resourceModel = GetResourceModel(locale, "Test", "Test", "Test", _getApplication.Execute(application.Name).ToContract());

            Post(resourceModel);

            _browser.Delete("/api/resources", with => { with.Query("id", "1"); });

            var resource = _getResource.Execute(application.Name, "Test", "Test", "Test");

            Assert.That(resource, Is.Null);

            _bootstrapper
            .Resolve <IMockClient>()
            .Received()
            .removeResource(Arg.Any <dynamic>());
        }