public void LoginWaiterTest() { //Arrange var waiterGuid = Guid.NewGuid(); var waiterLogin = "******"; var waiterPassword = "******"; var waiterFirstHash = HashUtility.CreateFirstHash(waiterPassword, waiterLogin); var waiterSecondHash = HashUtility.CreateSecondHashFromFirst(waiterFirstHash); var viewProviderMock = new Mock<IViewProvider>(); viewProviderMock.Setup(vp => vp.Get<WaiterView>()).Returns(new[] { new WaiterView() { FirstName = "firstName", LastName = "lastName", Login = waiterLogin, WaiterGuid = waiterGuid, WaiterId = 0, UserId = waiterGuid, SecondHash = waiterSecondHash } }.AsQueryable()); var unitOfWorkMock = new Mock<IUnitOfWork>(); unitOfWorkMock.Setup(uow => uow.Add(It.IsAny<ActiveUser>())).Returns<ActiveUser>(au => au); var commandBusMock = new Mock<ICommandBus>(); var accountController = new AccountController(unitOfWorkMock.Object, viewProviderMock.Object, commandBusMock.Object); var loginModel = new LoginModel() { Login = waiterLogin, FirstHash = waiterFirstHash }; //Act var actionResult = accountController.LoginWaiter(loginModel); //Assert var okNegotiatedContentResult = actionResult as OkNegotiatedContentResult<Guid>; Assert.IsNotNull(okNegotiatedContentResult); Assert.IsTrue(okNegotiatedContentResult.Content != Guid.Empty); }
public void LoginTableTest() { //Arrange var tableGuid = Guid.NewGuid(); var tableLogin = "******"; var tablePassword = "******"; var tableFirstHash = HashUtility.CreateFirstHash(tablePassword, tableLogin); var tableSecondHash = HashUtility.CreateSecondHashFromFirst(tableFirstHash); var viewProviderMock = new Mock<IViewProvider>(); viewProviderMock.Setup(vp => vp.Get<TableView>()).Returns(new[] { new TableView() { Title = "title", Description = "description", Login = tableLogin, TableGuid = tableGuid, TableId = 0, SecondHash = tableSecondHash, UserId = tableGuid} }.AsQueryable()); var unitOfWorkMock = new Mock<IUnitOfWork>(); unitOfWorkMock.Setup(uow => uow.Add(It.IsAny<ActiveUser>())).Returns<ActiveUser>(au => au); var commandBusMock = new Mock<ICommandBus>(); var accountController = new AccountController(unitOfWorkMock.Object, viewProviderMock.Object, commandBusMock.Object); var loginModel = new LoginModel() { Login = tableLogin, FirstHash = tableFirstHash }; //Act var actionResult = accountController.LoginTable(loginModel); //Assert var okNegotiatedContentResult = actionResult as OkNegotiatedContentResult<Guid>; Assert.IsNotNull(okNegotiatedContentResult); Assert.IsTrue(okNegotiatedContentResult.Content != Guid.Empty); }