public async Task TestInteractor_NotExist()
        {
            // ARRANGE
            //   Authorization Service Mocking
            var authServiceMock = new Mock <IAuthService>();

            authServiceMock.Setup(d => d.IsAuthenticated())
            .Returns(true);
            authServiceMock.Setup(d => d.IsAuthorized(AuthorizationRole.Admin))
            .Returns(true);

            //   Repository Mocking
            var repositoryMock = new Mock <IMotorcycleRepository>();

            //    Repository Get Mocking
            var tcs = new TaskCompletionSource <(Motorcycle, OperationStatus, IError)>();

            tcs.SetResult((null, OperationStatus.NotFound, new Error("Not Found")));
            repositoryMock.Setup(d => d.FetchByIdAsync(It.IsAny <long>()))
            .Returns(tcs.Task);
            var(request, _) = GetMotorcycleRequest.NewGetMotorcycleRequest(123);

            (GetMotorcycleInteractor interactor, _) = GetMotorcycleInteractor.NewGetMotorcycleInteractor(repositoryMock.Object, authServiceMock.Object);

            // ACT
            (_, IError error) = await interactor.HandleAsync(request);

            // ASSERT
            Assert.NotNull(error);
        }
        public async Task TestInteractor_Get()
        {
            // ARRANGE
            //   Authorization Service Mocking
            var authServiceMock = new Mock <IAuthService>();

            authServiceMock.Setup(d => d.IsAuthenticated())
            .Returns(true);
            authServiceMock.Setup(d => d.IsAuthorized(AuthorizationRole.Admin))
            .Returns(true);

            //   Repository Mocking
            (Motorcycle motorcycle, _) = Motorcycle.NewMotorcycle("Honda", "Shadow", 2006, "01234567890123456");
            motorcycle.Id = 1;
            var repositoryMock = new Mock <IMotorcycleRepository>();

            //    Repository Get Mocking
            var tcs = new TaskCompletionSource <(Motorcycle, OperationStatus, IError)>();

            tcs.SetResult((motorcycle, OperationStatus.Ok, null));
            repositoryMock.Setup(d => d.FetchByIdAsync(It.IsAny <long>()))
            .Returns(tcs.Task);
            var(request, _) = GetMotorcycleRequest.NewGetMotorcycleRequest(motorcycle.Id);

            (GetMotorcycleInteractor interactor, _) = GetMotorcycleInteractor.NewGetMotorcycleInteractor(repositoryMock.Object, authServiceMock.Object);

            // ACT
            (GetMotorcycleResponse response, _) = await interactor.HandleAsync(request);

            // ASSERT
            Assert.True(response.Motorcycle.Id == motorcycle.Id);
        }
        public void TestInteractor__MotorcycleRepositoryIsNull()
        {
            // ARRANGE
            var authServiceMock = new Mock <IAuthService>();

            // ACT
            (_, IError error) = GetMotorcycleInteractor.NewGetMotorcycleInteractor(null, authServiceMock.Object);


            // ASSERT
            Assert.NotNull(error);
        }
        public async Task TestInteractor_NotAuthenticated()
        {
            // ARRANGE
            var authServiceMock = new Mock <IAuthService>();

            authServiceMock.Setup(d => d.IsAuthenticated()).Returns(false);
            var repositoryMock = new Mock <IMotorcycleRepository>();

            var(request, _) = GetMotorcycleRequest.NewGetMotorcycleRequest(123);

            (GetMotorcycleInteractor interactor, _) = GetMotorcycleInteractor.NewGetMotorcycleInteractor(repositoryMock.Object, authServiceMock.Object);

            // ACT
            (_, IError error) = await interactor.HandleAsync(request);

            // ASSERT
            Assert.NotNull(error);
        }
        public void TestInteractor_AuthServiceIsNull()
        {
            // ARRANGE
            //            var roles = new Dictionary<AuthorizationRole, bool>
            //            {
            //                {
            //                    AuthorizationRole.None, true
            //                }
            //            };

            var repositoryMock = new Mock <IMotorcycleRepository>();

            // ACT
            (_, IError error) = GetMotorcycleInteractor.NewGetMotorcycleInteractor(repositoryMock.Object, null);


            // ASSERT
            Assert.NotNull(error);
        }