public async Task Request_object()
        {
            HandlerMock.SetupRestOperationObject(_restObjects);

            var restObject = await Application.CreateObjectSpace(typeof(RestOperationObject))
                             .Request <RestOperationObject>();

            restObject.Name.ShouldBe(_restObjects.Last().Name);
        }
        public async Task Create_object()
        {
            HandlerMock.SetupRestOperationObject(_restObjects);
            var objectSpace = Application.CreateObjectSpace(typeof(RestOperationObject));

            objectSpace.CreateObject <RestOperationObject>();

            objectSpace.CommitChanges();
            await RestService.Object.FirstAsync();
        }
        public async Task Delete_object()
        {
            var objectSpace = Application.CreateObjectSpace(typeof(RestOperationObject));
            var objects     = new[] { objectSpace.CreateObject <RestOperationObject>() };

            HandlerMock.SetupRestOperationObject(objects);
            var restObject = await objectSpace.Request <RestOperationObject>();

            objectSpace.Delete(restObject);
            objectSpace.CommitChanges();
            await RestService.Object.FirstAsync();
        }
        public void RestOperation_Action()
        {
            HandlerMock.SetupRestOperationObject(_restObjects);
            var window     = Application.CreateViewWindow();
            var detailView = Application.NewDetailView(typeof(RestOperationObject));

            window.SetView(detailView);

            var action = window.Action("Act");

            action.ShouldNotBeNull();
            action.Active.ResultValue.ShouldBeTrue();
            action.DoExecute(_ => new[] { detailView.CurrentObject });

            HandlerMock.VerifySend(Times.Exactly(1), message => $"{message.RequestUri}".Contains("Act"));
        }
Example #5
0
        public async Task Do_not_Cache_Post_Requests()
        {
            var objectSpace         = Application.CreateObjectSpace(typeof(RestOperationObject));
            var restOperationObject = objectSpace.CreateObject <RestOperationObject>();
            var objects             = new[] { restOperationObject };

            HandlerMock.SetupRestOperationObject(objects);
            var restObject = await objectSpace.Request <RestOperationObject>().Timeout(Timeout);

            restObject.Name = "1";
            objectSpace.CommitChanges();
            restObject.Name = "2";
            objectSpace.CommitChanges();
            await RestService.Object.FirstAsync().Timeout(Timeout);

            HandlerMock.VerifySend(Times.Exactly(2), message => $"{message.RequestUri}".Contains($"Update{nameof(RestOperationObject)}"));
        }
        public async Task Property_Operation_on_existing_object(bool isEnable, string name)
        {
            var objects = new[] { new RestOperationPropertyObject()
                                  {
                                      IsEnabled = !isEnable
                                  } };

            HandlerMock.SetupRestOperationObject(objects);
            var objectSpace = Application.CreateObjectSpace(typeof(RestOperationPropertyObject));
            var restObject  = await objectSpace.Request <RestOperationPropertyObject>();

            restObject.IsEnabled = isEnable;
            objectSpace.CommitChanges();

            await RestService.Object.FirstAsync(t =>
                                                t.message.RequestMessage?.RequestUri is not null && t.message.RequestMessage != null &&
                                                t.message.RequestMessage.RequestUri.AbsoluteUri.Contains(name));
        }