Ejemplo n.º 1
0
        public void GetById_WithDummyHeroes_ShouldThrowExceptionWhenItemNotFound()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedHeroes(context);

            this.heroService = new HeroService(context);

            int           heroId    = 777;
            DotaException exception = Assert.Throws <DotaException>(() => this.heroService.GetById(heroId));

            Assert.Equal(Constants.InvalidOperation, exception.Message);
        }
Ejemplo n.º 2
0
        public void GetById_WithDummyItems_ShouldThrowExceptionWhenItemNotFound()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedItems(context);

            this.itemService = new ItemService(context);

            int           itemId    = 123;
            DotaException exception = Assert.Throws <DotaException>(() => this.itemService.GetById(itemId));

            Assert.Equal(Constants.InvalidOperation, exception.Message);
        }
Ejemplo n.º 3
0
        public void Approve_WithDummyComments_ShouldThrowExceptionWhenCommentNotFound()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedComments(context);

            this.adminService = new AdminService(context);

            int commentId = 123;

            DotaException exception = Assert.Throws <DotaException>(() => this.adminService.Approve(commentId));

            Assert.Equal(Constants.InvalidOperation, exception.Message);
        }
Ejemplo n.º 4
0
        public void AddComment_WithDummy_ShouldThrowExceptionWhenItemNotFound()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedComments(context);

            this.commentService = new CommentService(context);

            var addCommentDto = new AddCommentDto
            {
                ItemId   = 777,
                Comment  = "New comment from test",
                Username = "******"
            };

            DotaException exception = Assert.Throws <DotaException>(() => this.commentService.AddComment(addCommentDto));

            Assert.Equal(Constants.InvalidOperation, exception.Message);
        }
Ejemplo n.º 5
0
        public void Update_WithDummyUses_ShouldThrowErrorIfUserWithThatUsernameDoesNotExist()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedUsers(context);

            var options = this.GetOptions();

            this.userService = new UserService(context, options);

            var updateUserDto = new UpdateUserDto
            {
                Username = "******"
            };

            DotaException exception = Assert.Throws <DotaException>(() => this.userService.Update(updateUserDto));

            Assert.Equal(Constants.UserNotFound, exception.Message);
        }
Ejemplo n.º 6
0
        public void Authenticate_WithDummyUsers_ShouldThrowErrorIfUserWithThatUsernameIsNotFound()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedUsers(context);

            var options = this.GetOptions();

            this.userService = new UserService(context, options);

            var usernamePasswordDto = new UsernamePasswordDto
            {
                Username = "******"
            };

            DotaException exception = Assert.Throws <DotaException>(() => this.userService.Authenticate(usernamePasswordDto));

            Assert.Equal(Constants.IncorrectUsernamePassword, exception.Message);
        }
Ejemplo n.º 7
0
        public void Register_WithDummyUsers_ShouldThrowErrorIfUsernameIsTaken()
        {
            var context = DotaAppContextInitializer.InitializeContext();

            this.SeedUsers(context);

            var options = this.GetOptions();

            this.userService = new UserService(context, options);

            var userDto = new UserDto
            {
                FirstName = "Pesho",
                LastName  = "Peshov",
                Email     = "*****@*****.**",
                Username  = "******"
            };

            DotaException exception = Assert.Throws <DotaException>(() => this.userService.Register(userDto));

            Assert.Equal(Constants.UsernameTaken, exception.Message);
        }