public async void Add_WithDataSourceAddReturningLeftDatabaseFailure_ShouldReturnLeftTodoFailureCacheDatabase()
        {
            // Arrange
            var service = CreateService();

            var itemToAdd = TodoItem.New(Guid.NewGuid(), false, "test content").SuccessAsEnumerable()[0];

            var items = List(
                new TodoItemDto(Guid.NewGuid(), false, "test content 1"),
                new TodoItemDto(Guid.NewGuid(), true, "test content 2")).ToSeq();

            var cacheResult         = Right <CacheFailure, Option <List <TodoItemDto> > >(None);
            var cacheSetResult      = Right <CacheFailure, Unit>(unit);
            var dataSourceFailure   = DatabaseFailureCon.Insert(Error.New("Datbase insert error"));
            var dataSourceAddResult = Left <DatabaseFailure, Unit>(dataSourceFailure);

            _mockCache
            .Setup(c => c.Get(It.IsAny <string>()))
            .Returns(cacheResult.ToAsync())
            .Verifiable();

            _mockCache
            .Setup(c => c.Set(It.IsAny <string>(), It.IsAny <List <TodoItemDto> >()))
            .Returns(cacheSetResult.ToAsync())
            .Verifiable();

            _mockDataSource
            .Setup(ds => ds.GetAll())
            .Returns(items)
            .Verifiable();

            _mockDataSource
            .Setup(ds => ds.Add(It.IsAny <TodoItemDto>()))
            .Returns(dataSourceAddResult.ToAsync());

            // Act
            var actual = service.Add(itemToAdd);

            // Assert
            await actual.ShouldBeLeft();

            await actual.ShouldBeLeft(f => f.ShouldBeOfType <TodoFailure.Database>());

            await actual.ShouldBeLeft(f => (f as TodoFailure.Database).Failure.ShouldBe(dataSourceFailure));
        }
        public async void GetAll_WithCacheReturningNoneAndDataSourceReturningLeftDatabaseFailure_ShouldReturnLeftTodoFailureDatabase()
        {
            // Arrange
            var service = CreateService();

            var items = List(
                new TodoItemDto(Guid.NewGuid(), false, "test content 1"),
                new TodoItemDto(Guid.NewGuid(), false, "test content 2")).ToSeq();

            var cacheResult       = Right <CacheFailure, Option <List <TodoItemDto> > >(None);
            var dataSourceFailure = DatabaseFailureCon.Retrieve(Error.New("Database retrieve error"));
            var dataSourceResult  = Left <DatabaseFailure, Seq <TodoItemDto> >(dataSourceFailure);

            _mockCache
            .Setup(c => c.Get(It.IsAny <string>()))
            .Returns(cacheResult.ToAsync())
            .Verifiable();

            _mockCache
            .Setup(c => c.Set(It.IsAny <string>(), It.IsAny <List <TodoItemDto> >()))
            .Returns(unit)
            .Verifiable();

            _mockDataSource
            .Setup(ds => ds.GetAll())
            .Returns(dataSourceResult.ToAsync())
            .Verifiable();

            // Act
            var actual = service.GetAll();

            // Assert
            await actual.ShouldBeLeft();

            await actual.ShouldBeLeft(f => f.ShouldBeOfType <TodoFailure.Database>());

            await actual.ShouldBeLeft(f => (f as TodoFailure.Database).Failure.ShouldBe(dataSourceFailure));
        }