コード例 #1
0
        public async Task UpdateUserTask_UpdateUserCallsConverter_UserCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();

            await _uut.UpdateUser(testUser);

            _fakeAppToDbModelConverter.Received().Convert(Arg.Is <UserModel>(um => um == testUser));
        }
コード例 #2
0
        public async Task UpdateUserTask_UpdateUserCallsDbContext_UserCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();

            await _uut.UpdateUser(testUser);

            await _fakeDbContext.Received().UpdateUserInformation(Arg.Any <User>());
        }
コード例 #3
0
        public async Task GetCarProfilesTask_CallsDbContextForUser_CallsDbWithCorrectUserModel()
        {
            var testUser = TestModelFactory.CreateUserModel();

            var dbCars = await _uut.GetCarProfilesTask(testUser);

            await _fakeDbContext.Received().GetUser(Arg.Is <string>(s => s == testUser.Email), Arg.Any <Guid>());
        }
コード例 #4
0
        public void UpdateUser_UserFirstNameUpdated_FirstNameCorrect()
        {
            var firstName = "TestFirstName";
            var lastName  = "TestLastName";

            _uut.UserModel = TestModelFactory.CreateUserModel(firstName, lastName);

            Assert.That(_uut.FirstName, Is.EqualTo(firstName));
        }
コード例 #5
0
        public void Notification_ShowNotifications_NotificationsSendToPopUp()
        {
            _fakeDatabaseQuery.GetUserTask(Arg.Any <UserModel>()).Returns(TestModelFactory.CreateUserModel());

            _uut.NotificationCommand.Execute(null);

            _fakeEventAggregator.GetEvent <NotificationMessagesUpdateEvent>()
            .Received().Publish(Arg.Is <List <MessageModel> >(noti => noti == _uut.UserModel.MessageModels));
        }
コード例 #6
0
        public async Task GetUserTask_GetUserCallsGetUserOnDbContext_EmailAndGuidCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();

            testUser.AuthenticationString = Guid.NewGuid();

            await _uut.GetUserTask(testUser);

            await _fakeDbContext.Received().GetUser(Arg.Is <string>(s => s == testUser.Email),
                                                    Arg.Is <Guid>(guid => guid == testUser.AuthenticationString));
        }
コード例 #7
0
        public async Task GetUserTask_GetUserReturnsExpectedUserModel_UserCorrect()
        {
            var testUser         = TestModelFactory.CreateUserModel();
            var expectedPassword = "******".ConvertToSecureString();

            _fakeDbToAppModelConverter.Convert(Arg.Any <User>()).Returns(testUser);

            var userResult = await _uut.GetUserTask(testUser.Email, expectedPassword);

            Assert.That(userResult, Is.EqualTo(testUser));
        }
コード例 #8
0
        public async Task GetUserTask_GetUserReturnsUserModel_UserCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();

            testUser.AuthenticationString = Guid.NewGuid();
            _fakeDbToAppModelConverter.Convert(Arg.Any <User>()).Returns(testUser);

            var userResult = await _uut.GetUserTask(testUser);

            Assert.That(userResult, Is.EqualTo(testUser));
        }
コード例 #9
0
        public async Task GetUserTask_GetUserCallsConverter_EmailAndGuidCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();

            _fakeDbContext.GetUser(Arg.Any <string>(), Arg.Any <Guid>()).Returns(new User()
            {
                Email = testUser.Email
            });

            await _uut.GetUserTask(testUser);

            _fakeDbToAppModelConverter.Received().Convert(Arg.Is <User>(u => u.Email == testUser.Email));
        }
コード例 #10
0
        public async Task UpdateUserMessagesTask_UpdateUserCallsConverter_MessagesCorrect()
        {
            var testUser          = TestModelFactory.CreateUserModel();
            var testMessageModels = new List <MessageModel> {
                TestModelFactory.CreateMessageModel()
            };

            _fakeAppToDbModelConverter.Convert(Arg.Any <List <MessageModel> >()).Returns(new List <Message>());

            await _uut.UpdateUserMessagesTask(testMessageModels);

            _fakeAppToDbModelConverter.Received().Convert(Arg.Is <List <MessageModel> >(m => m == testMessageModels));
        }
コード例 #11
0
        public async Task GetUserTask_GetUserCallsConverter_EmailAndPasswordCorrect()
        {
            var testUser         = TestModelFactory.CreateUserModel();
            var expectedPassword = "******".ConvertToSecureString();

            _fakeDbToAppModelConverter.Convert(Arg.Any <User>()).Returns(testUser);

            await _uut.GetUserTask(testUser.Email, expectedPassword);

            await _fakeDbContext.Received().GetUser(
                Arg.Is <string>(email => email == testUser.Email),
                Arg.Is <string>(pwd => pwd == expectedPassword.ConvertToString()));
        }
コード例 #12
0
        public async Task GetUserMessagesTask_GetUserMessagesReturnsExpectedUserModel_UserCorrect()
        {
            var testUser        = TestModelFactory.CreateUserModel();
            var testMessageList = new List <MessageModel>()
            {
                TestModelFactory.CreateMessageModel("Test", MessageType.LessorMessage)
            };

            _fakeDbToAppModelConverter.Convert(Arg.Any <List <Message> >()).Returns(testMessageList);

            var userMessageResult = await _uut.GetUserMessagesTask(testUser, 10);

            Assert.That(userMessageResult, Is.EqualTo(testMessageList));
        }
コード例 #13
0
        public async Task GetCarProfilesTask_CallsDbContextForAllCars_EmailCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();
            var fakeUser = new User()
            {
                Email = testUser.Email
            };

            _fakeDbContext.GetUser(Arg.Any <string>(), Arg.Any <Guid>()).Returns(fakeUser);

            await _uut.GetCarProfilesTask(testUser);

            await _fakeDbContext.Received().GetAllCars(Arg.Is <User>(u => u.Email == testUser.Email));
        }
コード例 #14
0
        public async Task GetUserMessagesTask_GetUserMessagesCallsConverter_MessageCorrect()
        {
            var testUser        = TestModelFactory.CreateUserModel();
            var testMessageList = new List <MessageModel>()
            {
                TestModelFactory.CreateMessageModel("Test", MessageType.LessorMessage)
            };

            _fakeDbToAppModelConverter.Convert(Arg.Any <List <Message> >()).Returns(testMessageList);

            await _uut.GetUserMessagesTask(testUser, 10);

            await _fakeDbContext.Received().GetUser(
                Arg.Is <string>(email => email == testUser.Email),
                Arg.Any <Guid>());
        }
コード例 #15
0
        public async Task GetCarProfilesTask_ReturnsCarProfile_EmailCorrect()
        {
            var testUser = TestModelFactory.CreateUserModel();
            var fakeUser = new User()
            {
                Email = testUser.Email
            };
            var fakeCarProfiles = new List <CarProfile>()
            {
                new CarProfile()
                {
                    OwnerEmail = testUser.Email,
                }
            };

            _fakeDbContext.GetUser(Arg.Any <string>(), Arg.Any <Guid>()).Returns(fakeUser);
            _fakeDbContext.GetAllCars(Arg.Any <User>()).Returns(fakeCarProfiles);

            await _uut.GetCarProfilesTask(testUser);

            _fakeDbToAppModelConverter.Received().Convert(Arg.Any <List <CarProfile> >());
        }
コード例 #16
0
        public async Task UpdateUserMessagesTask_UpdateUserCallsDbContext_UserCorrect()
        {
            var testMessages = new List <Message>()
            {
                new Message()
                {
                    TheMessage = "TestMsg1"
                },
                new Message()
                {
                    TheMessage = "TestMsg2"
                }
            };
            var testUser          = TestModelFactory.CreateUserModel();
            var testMessageModels = new List <MessageModel> {
                TestModelFactory.CreateMessageModel()
            };

            _fakeAppToDbModelConverter.Convert(Arg.Any <List <MessageModel> >()).Returns(testMessages);

            await _uut.UpdateUserMessagesTask(testMessageModels);

            await _fakeDbContext.Received(2).UpdateMessage(Arg.Is <Message>(msg => testMessages.Contains(msg)));
        }
コード例 #17
0
        public void TestSetup()
        {
            _fakeEventAggregator          = Substitute.For <IEventAggregator>();
            _fakeApplication              = Substitute.For <IApplication>();
            _fakeSearchEvent              = Substitute.For <SearchEvent>();
            _fakeDatabaseQuery            = Substitute.For <IQueryDatabase>();
            _fakeUserUpdateEvent          = Substitute.For <UserUpdateEvent>();
            _fakeUpdateEvent              = Substitute.For <NotificationMessagesUpdateEvent>();
            _fakeDatabasePollingLoopEvent = Substitute.For <DatabasePollingLoop>();
            _fakeEventAggregator.GetEvent <SearchEvent>().Returns(_fakeSearchEvent);
            _fakeEventAggregator.GetEvent <NotificationMessagesUpdateEvent>().Returns(_fakeUpdateEvent);
            _fakeEventAggregator.GetEvent <UserUpdateEvent>().Returns(_fakeUserUpdateEvent);
            _fakeEventAggregator.GetEvent <DatabasePollingLoop>().Returns(_fakeDatabasePollingLoopEvent);
            _uut = new HeaderBarViewModel(_fakeEventAggregator, _fakeApplication, _fakeDatabaseQuery);

            _fakeApplication.CurrentUser.Returns(TestModelFactory.CreateUserModel());

            _fakeDatabaseQuery.GetUserMessagesTask(Arg.Any <UserModel>(), Arg.Any <int>()).Returns(
                new List <MessageModel>()
            {
                TestModelFactory.CreateMessageModel("TestMsg", MessageType.LessorMessage)
            });
            _fakeDatabaseQuery.GetUserTask(Arg.Any <UserModel>()).Returns(TestModelFactory.CreateUserModel());
        }
コード例 #18
0
        public void UpdateUser_UserUpdateNumUnreadNotification_NumCorrect()
        {
            _uut.UserModel = TestModelFactory.CreateUserModel();

            Assert.That(_uut.NumUnreadNotifications, Is.GreaterThanOrEqualTo(0));
        }
コード例 #19
0
        public void UpdateUser_UserUpdateUnreadNotification_UnreadNotificationsTrue()
        {
            _uut.UserModel = TestModelFactory.CreateUserModel();

            Assert.That(_uut.UnreadNotifications, Is.True);
        }
コード例 #20
0
        public void UpdateUser_ManageCarsVisibleIfUserIsRentor_FirstNameCorrect(UserType type, bool expectedResult)
        {
            _uut.UserModel = TestModelFactory.CreateUserModel(type);

            Assert.That(_uut.ManageCarsVisible, Is.EqualTo(expectedResult));
        }