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