public async Task CreateAssignment_RightObjectPassed_ReturnsCreatedAtAction() { // Arrange var controller = new DeckAssignmentsController(flashcardDbContextMock.Object, GetMockUserManager().Object, emailService, logger); var rightAssignment = new DeckAssignmentDTO { Deck = new DeckInfoDTO() { Id = 2, Name = "Teszt csomag 2", Module = Module.A, Deck_number = 2, Status = DeckStatus.Approved }, User = new UserDTO() { Id = "268e543e-2020-ue63-a111-98321798c21", Email = "*****@*****.**", Name = "Teszt User 2", } }; // Act var result = await controller.CreateDeckAssignment(rightAssignment); // Asssert Assert.IsType <CreatedAtActionResult>(result.Result); }
public async Task CreateDeckAssignment_InvalidObjectPassed_ReturnsBadRequest() { // Arrange var controller = new DeckAssignmentsController(flashcardDbContextMock.Object, GetMockUserManager().Object, emailService, logger); var deckIdMissingAssignment = new DeckAssignmentDTO { Deck = new DeckInfoDTO() { Id = 2, Name = "Teszt csomag 2", Module = Module.A, Deck_number = 2, Status = DeckStatus.Approved }, User = new UserDTO() { Id = "268e543e-2020-ue63-a111-98321798c21", Email = "*****@*****.**", Name = "Teszt User 2", } }; controller.ModelState.AddModelError("DeckId", "Required"); // Act var result = await controller.CreateDeckAssignment(deckIdMissingAssignment); // Asssert Assert.IsType <BadRequestObjectResult>(result.Result); }
public async Task GetDeckAssignmentsByDeck_UnknownIdPassed_ReturnsNull() { // Arrange var controller = new DeckAssignmentsController(flashcardDbContextMock.Object, GetMockUserManager().Object, emailService, logger); int unknownDeckId = 22; // Act var result = await controller.GetDeckAssignmentsByDeck(unknownDeckId); // Asssert Assert.Null(result.Result); }
public async Task DeleteDeckAssignment_UnknownIdPassed_ReturnsNotFound() { // Arrange var controller = new DeckAssignmentsController(flashcardDbContextMock.Object, GetMockUserManager().Object, emailService, logger); int unknownDeckId = 16; string unknownUserId = "12316521"; // Act var result = await controller.DeleteDeckAssignment(unknownDeckId, unknownUserId); // Asssert Assert.IsType <NotFoundResult>(result); }
public async Task GetDeckAssignments_ReturnsAllAssignments() { // Arrange var controller = new DeckAssignmentsController(flashcardDbContextMock.Object, GetMockUserManager().Object, emailService, logger); // Act var result = await controller.GetDeckAssignments(); // Asssert var assignments = Assert.IsType <List <DeckAssignmentDTO> >(result.Value); Assert.Equal(2, assignments.Count); }