public void BuildAdapterPluginTest()
        {
            //Arrange and Act
            UserServiceFactory _harness1   = new UserServiceFactory();
            UserAdapter        userAdapter = _harness1.CreateUserAdapter();

            //Assert
            Assert.IsTrue(userAdapter is UserAdapter);
        }
        public void BuildServiceAdapterPluginTest()
        {
            //Arrange and Act
            UserServiceFactory _harness2   = new UserServiceFactory();
            UserService        userService = _harness2.CreateUserService();

            //Assert
            Assert.IsTrue(userService is UserService);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            UserServiceFactory userServiceFactory = new UserServiceFactory();
            IUserPlugin        userPlugin         = userServiceFactory.CreateUserPlugin("mysql");
            UserAdapter        userAdapter        = userServiceFactory.CreateUserAdapter(userPlugin);
            UserService        userService        = userServiceFactory.CreateUserService(userAdapter);

            services.AddSingleton <IUserService>(s => userService);
            services.AddRazorPages();
        }
Ejemplo n.º 4
0
        public async Task ShouldNotFindUser()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                FluentActions.Invoking(async() => await service.UpdateThemePreference(Guid.NewGuid(), true))
                .Should().Throw <UserNotFoundException>();
            }
        }
Ejemplo n.º 5
0
        public async Task EmailShouldNotExist()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = await service.EmailExists("*****@*****.**");

                result.Should().BeFalse();
            }
        }
Ejemplo n.º 6
0
        public async Task ShouldNotOwnEvent()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = await service.HostOwnsEvent(EventId, new Guid());

                result.Should().Be(false);
            }
        }
Ejemplo n.º 7
0
        public async Task PhoneShouldNotExist()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = await service.PhoneExists("1111111111");

                result.Should().BeFalse();
            }
        }
Ejemplo n.º 8
0
        public async Task ShouldGetUser()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = service.Get(new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C"));

                result.Should().NotBeNull();
            }
        }
Ejemplo n.º 9
0
        public async Task Should_Update()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = await service.UpdateAddress(UserId, Address);

                result.Should().Be(Address);
            }
        }
Ejemplo n.º 10
0
        public async Task ShouldAlreadyExist()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                FluentActions.Invoking(async() =>
                                       await service.UpdateUserName(new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C"),
                                                                    "ExistingUser"))
                .Should().Throw <UserNameAlreadyExistsException>();
            }
        }
        public void GetAllEmptyTest()
        {
            //Arrange
            UserServiceFactory _userServiceFactory = new UserServiceFactory();
            UserService        userService         = _userServiceFactory.CreateUserService();
            ArrayList          expected            = new ArrayList();
            //Act
            IEnumerable actual = userService.GetAll();

            //Assert
            Assert.AreEqual(expected.Count, (actual as ArrayList).Count);
        }
Ejemplo n.º 12
0
        public async Task ShouldUpdate()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result =
                    await service.UpdateUserName(new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C"), "UpdatedName");

                result.Should().NotBe("ExistingUser");
                result.Should().Be("UpdatedName");
            }
        }
Ejemplo n.º 13
0
        public async Task ShouldUpdate()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = await service.UpdateAvatar(new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C"),
                                                        new byte[] { 0, 0, 0, 0 });

                result.Should().NotBe(Encoding.UTF8.GetString(new Byte[] { 1, 1, 1, 1 }, 0, 4));
                result.Should().Be(Encoding.UTF8.GetString(new Byte[] { 0, 0, 0, 0 }, 0, 4));
            }
        }
Ejemplo n.º 14
0
        public async Task ShouldDestroyUser()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var id = new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C");
                await service.Destroy(id);

                var result = await context.Users.FirstOrDefaultAsync(x => x.Id == id);

                result.Should().BeNull();
            }
        }
Ejemplo n.º 15
0
        public async Task ShouldUpdate()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result =
                    await service.UpdateThemePreference(ValidUserId, true);

                result.Should().Be(true);

                var check = (await context.Users.FirstOrDefaultAsync(x => x.Id == ValidUserId)).IsDarkMode;
                check.Should().Be(true);
            }
        }
        public void AddNewUserSuccessTest()
        {
            //Arrange
            UserServiceFactory _userServiceFactory = new UserServiceFactory();
            string             email       = "*****@*****.**";
            UserService        userService = _userServiceFactory.CreateUserService();
            User expected = userService.CreateUser(email);

            userService.AddNewUser(email);
            //Act
            User actual = userService.FindUser(email);

            //Assert
            Assert.AreEqual(expected.Email, actual.Email);
        }
Ejemplo n.º 17
0
        public async Task Should_Get_Users_Analytics()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                var result = await service.GetAnalytics(new Guid("046E876E-D413-45AF-AC2A-552D7AA46C5C"));

                result.Should().NotBeNull();

                result.RecommendationScores.Should().NotContainNulls();
                result.SearchEvents.Should().NotContainNulls().And.BeInDescendingOrder(x => x.Created);
                result.PageViewEvents.Should().NotContainNulls().And.BeInDescendingOrder(x => x.Created);
                result.TicketVerificationEvents.Should().NotContainNulls().And.BeInDescendingOrder(x => x.Created);
            }
        }
Ejemplo n.º 18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            UserServiceFactory userServiceFactory = new UserServiceFactory();
            iUserPlugin        userPlugin         = userServiceFactory.CreateUserPlugin("mysql");
            UserAdapter        userAdapter        = userServiceFactory.CreateUserAdapter(userPlugin);
            UserService        userService        = userServiceFactory.CreateUserService(userAdapter);

            BlabServiceFactory blabServiceFactory = new BlabServiceFactory();
            iBlabPlugin        blabPlugin         = blabServiceFactory.CreateBlabPlugin("mysql");
            BlabAdapter        blabAdapter        = blabServiceFactory.CreateBlabAdapter(blabPlugin);
            BlabService        blabService        = blabServiceFactory.CreateBlabService(blabAdapter);

            services.AddSingleton <iUserService>(s => userService);
            services.AddSingleton <iBlabService>(s => blabService);
            services.AddRazorPages();
        }
Ejemplo n.º 19
0
        public async Task ShouldFailNonUniqueUser()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                NewUserBody user = new NewUserBody()
                {
                    Email    = "*****@*****.**",
                    Password = "******",
                    UserName = "******"
                };

                FluentActions.Invoking(async() => await service.Create(user))
                .Should().Throw <UserAlreadyExistsException>();
            }
        }
Ejemplo n.º 20
0
        public async Task ShouldCreateNewUser()
        {
            await using (var context = new DbContextFactory().CreateContext())
            {
                var service = new UserServiceFactory().Create(context);

                NewUserBody user = new NewUserBody()
                {
                    Email       = "*****@*****.**",
                    Password    = "******",
                    FirstName   = "Joe",
                    LastName    = "Blogs",
                    UserName    = "******",
                    PhoneNumber = "1111111111",
                    Avatar      = new byte[100],
                    DateOfBirth = DateTime.Now.AddYears(-18)
                };

                await service.Create(user);
            }
        }
 //Constructor
 public UserServiceFactoryTest()
 {
     this.harness = new UserServiceFactory();
 }
 public WebApiHomeController()
 {
     _userService = UserServiceFactory.GetUserService();
 }