Exemplo n.º 1
0
            public void HandlesNullValueReceivedFromTheServerAsAnEmptyList()
            {
                var oldSinceParameters     = new SinceParameters(null);
                List <TInterface> entities = null;
                var observables            = CreateObservables(oldSinceParameters, entities);

                var transition = (Transition <FetchObservables>)state.Start(observables).SingleAsync().Wait();

                transition.Result.Should().Be(state.FinishedPersisting);
                assertBatchUpdateWasCalled(new List <TInterface>());
            }
Exemplo n.º 2
0
            public void PassesTheNewSinceParametersThroughTheTransition()
            {
                var oldSinceParameters = new SinceParameters(null, at);
                var entities           = CreateComplexListWhereTheLastUpdateEntityIsDeleted(at);
                var observables        = CreateObservables(oldSinceParameters, entities);

                setupDatabaseBatchUpdateMocksToReturnUpdatedDatabaseEntitiesAndSimulateDeletionOfEntities(entities);

                var transition = (Transition <FetchObservables>)state.Start(observables).SingleAsync().Wait();

                transition.Parameter.SinceParameters.Should()
                .Match((ISinceParameters newSinceParameters) => OtherSinceDatesDidntChange(oldSinceParameters, newSinceParameters, at));
            }
Exemplo n.º 3
0
            public void SelectsTheLatestAtValue()
            {
                var oldSinceParameters = new SinceParameters(null);
                var entities           = CreateComplexListWhereTheLastUpdateEntityIsDeleted(at);
                var observables        = CreateObservables(oldSinceParameters, entities);

                setupDatabaseBatchUpdateMocksToReturnUpdatedDatabaseEntitiesAndSimulateDeletionOfEntities(entities);

                state.Start(observables).SingleAsync().Wait();

                sinceParameterRepository.Received().Set(Arg.Is <ISinceParameters>(
                                                            (newSinceParameters) => OtherSinceDatesDidntChange(oldSinceParameters, newSinceParameters, at)));
            }
Exemplo n.º 4
0
            public void UpdatesSinceParametersOfTheFetchedEntity()
            {
                var oldAt = new DateTimeOffset(2017, 09, 01, 12, 34, 56, TimeSpan.Zero);
                var newAt = new DateTimeOffset(2017, 10, 01, 12, 34, 56, TimeSpan.Zero);
                var oldSinceParameters = new SinceParameters(null, oldAt);
                var entities           = CreateListWithOneItem(newAt);
                var observables        = CreateObservables(oldSinceParameters, entities);

                setupDatabaseBatchUpdateMocksToReturnUpdatedDatabaseEntitiesAndSimulateDeletionOfEntities(entities);

                state.Start(observables).SingleAsync().Wait();

                sinceParameterRepository.Received().Set(Arg.Is <ISinceParameters>(
                                                            newSinceParameters => OtherSinceDatesDidntChange(oldSinceParameters, newSinceParameters, newAt)));
            }
Exemplo n.º 5
0
            public void SinceDatesAreNotUpdatedWhenBatchUpdateThrows()
            {
                var oldSinceParameters = new SinceParameters(null, at);
                var entities           = CreateComplexListWhereTheLastUpdateEntityIsDeleted(at);
                var observables        = CreateObservables(oldSinceParameters, entities);

                setupBatchUpdateToThrow(new TestException());

                try
                {
                    state.Start(observables).SingleAsync().Wait();
                }
                catch (TestException) { }

                sinceParameterRepository.DidNotReceiveWithAnyArgs().Set(null);
            }
        public IObservable <ITransition> Start() => Observable.Create <ITransition>(observer =>
        {
            var databaseSinceDates = database.SinceParameters.Get();
            var sinceDates         = new SinceParameters(databaseSinceDates);

            var observables = new FetchObservables(sinceDates,
                                                   api.Workspaces.GetAll().ConnectedReplay(),
                                                   api.WorkspaceFeatures.GetAll().ConnectedReplay(),
                                                   getSinceOrAll(sinceDates.Clients, api.Clients.GetAllSince, api.Clients.GetAll).ConnectedReplay(),
                                                   getSinceOrAll(sinceDates.Projects, api.Projects.GetAllSince, api.Projects.GetAll).ConnectedReplay(),
                                                   getSinceOrAll(sinceDates.TimeEntries, api.TimeEntries.GetAllSince, api.TimeEntries.GetAll).ConnectedReplay(),
                                                   getSinceOrAll(sinceDates.Tags, api.Tags.GetAllSince, api.Tags.GetAll).ConnectedReplay(),
                                                   getSinceOrAll(sinceDates.Tasks, api.Tasks.GetAllSince, api.Tasks.GetAll).ConnectedReplay()
                                                   );

            observer.OnNext(FetchStarted.Transition(observables));
            observer.OnCompleted();

            return(() => { });
        });
Exemplo n.º 7
0
            public void DoesNotUpdateSinceParametersWhenNothingIsFetched()
            {
                var oldSinceParameters = new SinceParameters(
                    null,
                    workspaces: at,
                    clients: at.AddDays(1),
                    projects: at.AddDays(2),
                    tags: at.AddDays(3),
                    tasks: at.AddDays(4),
                    timeEntries: at.AddDays(5)
                    );
                var observables = CreateObservables(oldSinceParameters);

                state.Start(observables).SingleAsync().Wait();

                sinceParameterRepository.Received().Set(Arg.Is <ISinceParameters>(
                                                            newSinceParameters =>
                                                            newSinceParameters.Workspaces == oldSinceParameters.Workspaces &&
                                                            newSinceParameters.Projects == oldSinceParameters.Projects &&
                                                            newSinceParameters.Clients == oldSinceParameters.Clients &&
                                                            newSinceParameters.Tags == oldSinceParameters.Tags &&
                                                            newSinceParameters.Tasks == oldSinceParameters.Tasks));
            }