public void ArchivePost_Flow_RedirectToRouteResult() { // Arrange var mainUser = new User { Id = 1, FirstName = "Unit", LastName = "Test", UserName = "******", Mail = "*****@*****.**" }; var users = new List <User>() { mainUser }.AsQueryable(); var mainGroup = new Group { Id = 1, GroupName = "Unit Group", Users = users.ToList(), Archived = false }; var groups = new List <Group>() { mainGroup }.AsQueryable(); var mockContext = new Mock <Context>(); var mockGroups = MockHelper.MockDbSet(groups); mockContext.SetupGet(c => c.Groups).Returns(mockGroups.Object); var mockUserHelper = new Mock <IUserHelper>(); mockUserHelper.Setup(x => x.GetCurrentUser().Id).Returns(mainUser.Id); var controller = new GroupController(mockContext.Object, mockUserHelper.Object); var vm = new Models.Group.GroupVM { Id = mainGroup.Id }; // Act RedirectToRouteResult result = controller.Archive(vm) as RedirectToRouteResult; // Assert Assert.IsNotNull(result); }
public void NewGroup_Flow_ViewResult() { //Arange var mockContext = new Mock <Context>(); var controller = new GroupController(mockContext.Object); var vm = new Models.Group.GroupVM { Message = "Unit Message" }; // Act ViewResult result = controller.NewGroup(vm) as ViewResult; // Assert Assert.IsNotNull(result); }
public void NewEventPost_IsNullOrWhiteSpace_RedirectToRouteResult() { // Arrange var mainUser = new User { Id = 1, FirstName = "Unit", LastName = "Test", UserName = "******", Mail = "*****@*****.**" }; var users = new List <User>() { mainUser }.AsQueryable(); var mainGroup = new Group { Id = 1, Archived = true, }; var groups = new List <Group>() { mainGroup }.AsQueryable(); var events = new List <Event>().AsQueryable(); var mockContext = new Mock <Context>(); var mockGroups = MockHelper.MockDbSet(groups); mockContext.SetupGet(c => c.Groups).Returns(mockGroups.Object); var mockUsers = MockHelper.MockDbSet(users); mockContext.SetupGet(c => c.Users).Returns(mockUsers.Object); var mockEvents = MockHelper.MockDbSet(events); mockContext.SetupGet(c => c.Events).Returns(mockEvents.Object); var mockUserHelper = new Mock <IUserHelper>(); mockUserHelper.Setup(x => x.GetCurrentDbUser(mockContext.Object)).Returns(mainUser); var controller = new GroupController(mockContext.Object, mockUserHelper.Object); var vmEventNameNotNullOrWhiteSpaceGroupNotNull = new Models.Group.GroupVM { Id = mainGroup.Id, NewEventName = "Unit Event", Archived = false }; var vmEventNameNotNullOrWhiteSpaceGroupNull = new Models.Group.GroupVM { Id = 0, NewEventName = "Unit Event", Archived = false }; var vmEventNameNotNullOrWhiteSpaceGroupNotNullArchived = new Models.Group.GroupVM { Id = mainGroup.Id, NewEventName = "Unit Event", Archived = true }; var vmEventNameNull = new Models.Group.GroupVM { Id = mainGroup.Id, NewEventName = null }; var vmEventNameWhiteSpace = new Models.Group.GroupVM { Id = mainGroup.Id, NewEventName = "" }; // Act RedirectToRouteResult resultEventNameNotNullOrWhiteSpaceGroupNotNull = controller.NewEvent(vmEventNameNotNullOrWhiteSpaceGroupNotNull) as RedirectToRouteResult; RedirectToRouteResult resultEventNameNotNullOrWhiteSpaceGroupNull = controller.NewEvent(vmEventNameNotNullOrWhiteSpaceGroupNotNullArchived) as RedirectToRouteResult; RedirectToRouteResult resultEventNameNotNullOrWhiteSpaceGroupNotNullArchived = controller.NewEvent(vmEventNameNotNullOrWhiteSpaceGroupNull) as RedirectToRouteResult; RedirectToRouteResult resultEventNameNull = controller.NewEvent(vmEventNameNull) as RedirectToRouteResult; RedirectToRouteResult resultEventNameWhiteSpace = controller.NewEvent(vmEventNameNull) as RedirectToRouteResult; // Assert Assert.IsNotNull(resultEventNameNotNullOrWhiteSpaceGroupNotNull); Assert.IsNotNull(resultEventNameNotNullOrWhiteSpaceGroupNull); Assert.IsNotNull(resultEventNameNotNullOrWhiteSpaceGroupNotNullArchived); Assert.IsNotNull(resultEventNameNull); Assert.IsNotNull(resultEventNameWhiteSpace); }
public void NewGroupPost_IsNullOrWhiteSpace_ViewResult() { // Arrange var mainUser = new User { Id = 1, FirstName = "Unit", LastName = "Test", UserName = "******", Mail = "*****@*****.**" }; var mainGroup = new Group { Id = 1, Archived = true }; var groups = new List <Group>() { mainGroup }.AsQueryable(); var mockContext = new Mock <Context>(); var mockGroups = MockHelper.MockDbSet(groups); mockContext.SetupGet(c => c.Groups).Returns(mockGroups.Object); var mockUserHelper = new Mock <IUserHelper>(); mockUserHelper.Setup(x => x.GetCurrentUser().Id).Returns(mainUser.Id); var controller = new GroupController(mockContext.Object, mockUserHelper.Object); var vmGroupNameNotNullOrWhiteSpace = new Models.Group.GroupVM { Id = mainGroup.Id, GroupName = "Unit Group", Category = "Unit Category" }; var vmGroupNameNull = new Models.Group.GroupVM { Id = mainGroup.Id, GroupName = null }; var vmGroupNameWhiteSpace = new Models.Group.GroupVM { Id = mainGroup.Id, GroupName = "" }; // Act ViewResult resultGroupNotNullOrWhiteSpace = controller.NewGroup(vmGroupNameNotNullOrWhiteSpace) as ViewResult; ViewResult resultGroupNull = controller.NewGroup(vmGroupNameNull) as ViewResult; ViewResult resultGroupWhiteSpace = controller.NewGroup(vmGroupNameWhiteSpace) as ViewResult; // Assert Assert.IsNotNull(resultGroupNotNullOrWhiteSpace); Assert.IsNotNull(resultGroupNull); Assert.IsNotNull(resultGroupWhiteSpace); }