Exemple #1
0
        public async Task getAnnouncementsTest()
        {
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.AddJsonFile("AppSettings.json");
            IConfiguration configuration = configurationBuilder.Build();

            GymRepository gym = new GymRepository(DbContext);
            await gym.addGym(new Gym { GymName = "testName", GymBranch = "testBranch" });

            NotificationsRepository notif = new NotificationsRepository(DbContext);


            await notif.addNotification(new Notifications
                                        { Body = "body", Date = DateTime.Now, Heading = "heading", GymIdForeignKey = 1 });

            var controller = new NotificationsController(new NotificationSettingsRepository(DbContext),
                                                         notif, gym, new Mailer(configuration));


            var okObjectResult = Assert.IsType <Task <ActionResult <Notifications[]> > >(controller.getAllAnnouncements(1));


            //Assert.IsNotType<string>(okObjectResult.Value);
        }
Exemple #2
0
        public async Task ChangePassword()
        {
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.AddJsonFile("AppSettings.json");
            IConfiguration configuration = configurationBuilder.Build();

            GymRepository gym = new GymRepository(DbContext);
            await gym.addGym(new Gym { GymName = "testName", GymBranch = "testBranch" });

            GymMemberRepository gymMember = new GymMemberRepository(DbContext);
            bool add = await gymMember.addMember(new GymMember
            {
                MembershipId = "1",
                Email        = "*****@*****.**",
                GymId        = 1,
                Name         = "name",
                Surname      = "surname",
                PhoneNumber  = "0321456956",
                UserType     = Data.Enums.UserTypes.Instructor
            });

            Assert.True(add);


            var userController = new UserController(new UserRepository(DbContext), gymMember,
                                                    gym, new NotificationSettingsRepository(DbContext), new PasswordResetRepository(DbContext),
                                                    new Mailer(configuration), new GymApplicationRepository(DbContext), new ApplicationCodeRepository(DbContext));

            ActionResult <UserResponseModel> signedup = await userController.signUp(new SignUpRequestModel
            {
                username    = "******",
                password    = "******",
                gymBranch   = "testBranch",
                gymMemberId = "1",
                gymName     = "testName"
            });

            ActionResult <UserResponseModel> changedPassword = await userController.changePassword(new ChangePasswordRequestModel
            {
                username    = "******",
                oldPassword = "******",
                newPassword = "******",
            });

            var okObjectResult = Assert.IsType <ActionResult <UserResponseModel> >(changedPassword);

            Assert.IsNotType <string>(okObjectResult.Value);
        }