예제 #1
0
        public async void GetTask_Valid_IsTask_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedTask));
            var taskAdapter = new TaskAdapter(_repositoryMock.Object);

            //Act
            var returnedTask = await taskAdapter.Read(idToRead);

            //Assert
            Assert.IsInstanceOfType(returnedTask, typeof(TaskRequest));
        }
예제 #2
0
        public async void GetTask_Valid_NotNull_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedTask));
            var taskAdapter = new TaskAdapter(_repositoryMock.Object);

            //Act
            var returnedTask = await taskAdapter.Read(idToRead);

            //Assert
            Assert.IsNotNull(returnedTask);
        }
예제 #3
0
        public void CreateTask_Success_Test()
        {
            //Arrange 
            const int expectedReturnId = 0; 
            _repositoryMock.Setup(r => r.Create(_storedTask)).Returns(Task.FromResult(expectedReturnId));
            var taskAdapter = new TaskAdapter(_repositoryMock.Object);
            
            //Act
            var actualId = taskAdapter.Read(_storedTask.Id).Id;

            //Assert
            Assert.IsTrue(expectedReturnId == actualId);
        }
예제 #4
0
        public async void GetTask_Valid_CorrectTaskInfo_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead)).Returns(Task.FromResult(_storedTask));
            var adapter = new TaskAdapter(_repositoryMock.Object);

            //Act
            var actualTask = await adapter.Read(idToRead);
            
            //Assert
            Assert.IsTrue(_task.Id == actualTask.Id);
            Assert.IsTrue(_task.Description == actualTask.Description);
            // TODO add more? 

        }
예제 #5
0
        public void GetAllTasks_Valid_ReturnsCorrectTasks_Test()
        {
            // TODO add property values 
            //Arrange
            var task1 = new StoredTaskRequest { Id = 0};
            var task2 = new StoredTaskRequest { Id = 1};
            var task3 = new StoredTaskRequest { Id = 2};
            var taskList = new List<StoredTaskRequest> { task1, task2, task3 }.AsQueryable();

            _repositoryMock.Setup(r => r.Read()).Returns(taskList);
            var adapter = new TaskAdapter(_repositoryMock.Object);

            //Act
            var result = adapter.Read();
            var actualTasks = result.ToList();

            //Assert
            var counter = 0;
            foreach (var actualTask in taskList.AsEnumerable())
            {
                var returnedTask = actualTasks[counter];
                // Todo add property asserts 
                Assert.IsTrue(returnedTask.Id == actualTask.Id);
                counter++;
            }

        }
예제 #6
0
        public void GetAllTasks_Valid_ReturnsCorrectNumberOfTasks_Test()
        {
            //Arrange
            var task1 = new StoredTaskRequest { }; 
            var task2 = new StoredTaskRequest { };
            var task3 = new StoredTaskRequest { };
            var taskList = new List<StoredTaskRequest> { task1, task2, task3 }.AsQueryable();

            _repositoryMock.Setup(r => r.Read()).Returns(taskList);
            var adapter = new TaskAdapter(_repositoryMock.Object);
            const int expectedCount = 3;

            //Act
            var result = adapter.Read();
            var actualCount = result.ToList().Count;

            //Assert
            Assert.IsTrue(expectedCount == actualCount);
        }
예제 #7
0
        public async void GetTask_Invalid_NoExistingTask_Test()
        {
            //Arrange
            const int idToRead = 0;
            _repositoryMock.Setup(r => r.Read(idToRead));
            var adapter = new TaskAdapter(_repositoryMock.Object);

            //Act
            var returnedTask = await adapter.Read(idToRead);

            //Assert
            Assert.IsNull(returnedTask);
        }