コード例 #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);
        }
コード例 #2
0
ファイル: ItemServiceTests.cs プロジェクト: VanGog06/DotaApp
        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);
        }
コード例 #3
0
ファイル: AdminServiceTests.cs プロジェクト: VanGog06/DotaApp
        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);
        }
コード例 #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);
        }
コード例 #5
0
ファイル: UserServiceTests.cs プロジェクト: VanGog06/DotaApp
        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);
        }
コード例 #6
0
ファイル: UserServiceTests.cs プロジェクト: VanGog06/DotaApp
        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);
        }
コード例 #7
0
ファイル: UserServiceTests.cs プロジェクト: VanGog06/DotaApp
        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);
        }