示例#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);
            }
示例#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);
            }
示例#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);
            }
示例#4
0
 protected override void PrepareApiCallFunctionToThrow(Exception e)
 => GetDeleteFunction(api)(Arg.Any <TModel>())
 .Returns(_ => Observable.Throw <Unit>(e));