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)); }
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); }
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); }
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? }
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++; } }
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); }
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); }