Ejemplo n.º 1
0
            public void MakesApiCallWithCorrectParameter()
            {
                var state  = createDeleteState(api, repository);
                var entity = CreateDirtyEntityWithNegativeId();

                GetDeleteFunction(api)(entity)
                .Returns(Observable.Return(Unit.Default));

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

                GetDeleteFunction(api).Received().Invoke(entity);
            }
Ejemplo n.º 2
0
            public void CallsDatabaseDeleteOperationWithCorrectParameter()
            {
                var state  = createDeleteState(api, repository);
                var entity = CreateDirtyEntityWithNegativeId();

                GetDeleteFunction(api)(entity)
                .Returns(Observable.Return(Unit.Default));

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

                repository.Received().Delete(entity.Id);
            }
Ejemplo n.º 3
0
            public void ReturnsSuccessfulTransitionWhenEverythingWorks()
            {
                var state          = createDeleteState(api, repository);
                var entity         = CreateDirtyEntityWithNegativeId();
                var clean          = CreateCleanEntityFrom(entity);
                var withPositiveId = CreateCleanWithPositiveIdFrom(entity);

                GetDeleteFunction(api)(Arg.Any <TModel>())
                .Returns(Observable.Return(Unit.Default));
                repository.Delete(Arg.Any <long>())
                .Returns(Observable.Return(Unit.Default));

                var transition = state.Start(entity).SingleAsync().Wait();

                transition.Result.Should().Be(state.DeletingFinished);
            }
Ejemplo n.º 4
0
 protected override void PrepareApiCallFunctionToThrow(Exception e)
 => GetDeleteFunction(api)(Arg.Any <TModel>())
 .Returns(_ => Observable.Throw <Unit>(e));