public void FoodTruckWithEmptyNameFails()
        {
            // Arrange
            var model = new CreateFoodTruckModelV11()
            {
                Name        = "",
                Description = "Some very interesting description",
                Website     = @"http://www.foodtruck.com",
                Tags        = new List <string>()
                {
                    "Burgers", "Sandwiches"
                }
            };
            var mockSocialMediaService = new Mock <ISocialMediaPlatformService>();

            mockSocialMediaService.Setup(m => m.GetAllSocialMediaPlatforms())
            .Returns(Result.Success <List <SocialMediaPlatform> >(new List <SocialMediaPlatform>()));

            // Act
            var validator = new CreateFoodTruckModelV11Validator(mockSocialMediaService.Object);
            var result    = validator.Validate(model);

            // Assert
            result.IsValid.Should().BeFalse();
        }
        public void ValidWebsitesPass(string website)
        {
            // Arrange
            var model = new CreateFoodTruckModelV11()
            {
                Name        = "Food Truck Name",
                Description = "Some very interesting description",
                Website     = website,
                Tags        = new List <string>()
                {
                    "Burgers", "Sandwiches"
                }
            };
            var mockSocialMediaService = new Mock <ISocialMediaPlatformService>();

            mockSocialMediaService.Setup(m => m.GetAllSocialMediaPlatforms())
            .Returns(Result.Success <List <SocialMediaPlatform> >(new List <SocialMediaPlatform>()));

            // Act
            var validator = new CreateFoodTruckModelV11Validator(mockSocialMediaService.Object);
            var result    = validator.Validate(model);

            // Assert
            result.IsValid.Should().BeTrue();
        }
Exemple #3
0
        public void TagsArrayCannotContainInvalidEntries()
        {
            // Arrange
            var model = new CreateFoodTruckModelV11()
            {
                Name        = "Food Truck Name",
                Description = "Some very interesting description",
                Website     = @"http://www.foodtruck.com",
                Tags        = new List <string>()
                {
                    "Burgers", "Pizza@"
                }
            };
            var mockSocialMediaService = new Mock <ISocialMediaPlatformService>();

            mockSocialMediaService.Setup(m => m.GetAllSocialMediaPlatforms())
            .Returns(new List <SocialMediaPlatform>());

            // Act
            var validator = new CreateFoodTruckModelV11Validator(mockSocialMediaService.Object);
            var result    = validator.Validate(model);

            // Assert
            result.IsValid.Should().BeFalse();
        }
        public void TagsArrayCanBeNull()
        {
            // Arrange
            var model = new CreateFoodTruckModelV11()
            {
                Name        = "Food Truck Name",
                Description = "Some very interesting description",
                Website     = @"http://www.foodtruck.com",
                Tags        = null
            };
            var mockSocialMediaService = new Mock <ISocialMediaPlatformService>();

            mockSocialMediaService.Setup(m => m.GetAllSocialMediaPlatforms())
            .Returns(Result.Success <List <SocialMediaPlatform> >(new List <SocialMediaPlatform>()));

            // Act
            var validator = new CreateFoodTruckModelV11Validator(mockSocialMediaService.Object);
            var result    = validator.Validate(model);

            // Assert
            result.IsValid.Should().BeTrue();
        }
        public void SocialMediaAccountFailsWhenPlatformDoesNotExist()
        {
            // Arrange
            var model = new CreateFoodTruckModelV11()
            {
                Name        = "Food Truck Name",
                Description = "Some very interesting description",
                Website     = @"http://www.foodtruck.com",
                Tags        = new List <string>()
                {
                    "Burgers", "Pizza"
                },
                SocialMediaAccounts = new List <CreateFoodTruckModelV11.SocialMediaAccountModel>()
                {
                    new CreateFoodTruckModelV11.SocialMediaAccountModel()
                    {
                        SocialMediaPlatformId = 2,
                        AccountName           = "MostAwesomeFoodTruck"
                    }
                }
            };
            var mockSocialMediaService = new Mock <ISocialMediaPlatformService>();

            mockSocialMediaService.Setup(m => m.GetAllSocialMediaPlatforms())
            .Returns(Result.Success <List <SocialMediaPlatform> >(new List <SocialMediaPlatform>()
            {
                new SocialMediaPlatform(1, "FooTruckMedia", "", @"\w{1,20}")
            }));


            // Act
            var validator = new CreateFoodTruckModelV11Validator(mockSocialMediaService.Object);
            var result    = validator.Validate(model);

            // Assert
            result.IsValid.Should().BeFalse();
        }