Beispiel #1
0
 public void IndicatingControllerShouldNotThrowExceptionWithTheAttribute()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes(attributes => attributes
                 .IndicatingViewComponentExplicitly());
 }
 public void PassingForShouldNotThrowExceptionWithCorrectPredicate()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes(attributes => attributes
                 .PassingFor <ViewComponentAttribute>(route => route.Name == "Test"));
 }
 public void PassingForShouldNotThrowExceptionWithCorrectAssertions()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes(attributes => attributes
                 .PassingFor <ViewComponentAttribute>(vc => Assert.Equal("Test", vc.Name)));
 }
 public void AndAlsoShouldWorkCorrectly()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes(attributes => attributes
                 .PassingFor <ViewComponentAttribute>(viewComponent => viewComponent.Name == "Test")
                 .AndAlso()
                 .ContainingAttributeOfType <ViewComponentAttribute>());
 }
 public void AndProvideTheControllerAttributesShouldReturnProperAttributes()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes()
     .ShouldPassForThe <ViewComponentAttributes>(attributes =>
     {
         Assert.Equal(2, attributes.Count());
     });
 }
 public void AttributesShouldThrowEceptionWithControllerContainingNumberOfAttributesTestingWithOne()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <AttributesComponent>
         .ShouldHave()
         .Attributes(withTotalNumberOf: 1);
     },
         "When testing AttributesComponent was expected to have 1 attribute, but in fact found 2.");
 }
 public void AttributesShouldThrowEceptionWithControllerContainingNoAttributes()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <NormalComponent>
         .ShouldHave()
         .Attributes();
     },
         "When testing NormalComponent was expected to have at least 1 attribute, but in fact none was found.");
 }
 public void NoAttributesShouldThrowExceptionWithControllerContainingAttributes()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <AttributesComponent>
         .ShouldHave()
         .NoAttributes();
     },
         "When testing AttributesComponent was expected to not have any attributes, but it had some.");
 }
 public void PassingForShouldThrowExceptionWithIncorrectAssertions()
 {
     Assert.ThrowsAny <Exception>(
         () =>
     {
         MyViewComponent <AttributesComponent>
         .ShouldHave()
         .Attributes(attributes => attributes
                     .PassingFor <ViewComponentAttribute>(route => Assert.Equal("Invalid", route.Name)));
     });
 }
Beispiel #10
0
 public void DisablingActionCallShouldThrowExceptionWithActionWithoutTheAttribute()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <ComponentWithCustomAttribute>
         .ShouldHave()
         .Attributes(attributes => attributes
                     .IndicatingViewComponentExplicitly());
     },
         "When testing ComponentWithCustomAttribute was expected to have ViewComponentAttribute, but in fact such was not found.");
 }
 public void PassingForShouldThrowExceptionWithIncorrectAttributeWithPredicate()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <AttributesComponent>
         .ShouldHave()
         .Attributes(attributes => attributes
                     .PassingFor <ActionNameAttribute>(vc => vc.Name == "Admin"));
     },
         "When testing AttributesComponent was expected to have ActionNameAttribute, but in fact such was not found.");
 }
 public void PassingForShouldThrowExceptionWithIncorrectPredicate()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <AttributesComponent>
         .ShouldHave()
         .Attributes(attributes => attributes
                     .PassingFor <ViewComponentAttribute>(vc => vc.Name == "Invalid"));
     },
         "When testing AttributesComponent was expected to have ViewComponentAttribute passing the given predicate, but it failed.");
 }
 public void PassingForShouldThrowExceptionWithIncorrectAttribute()
 {
     Test.AssertException <AttributeAssertionException>(
         () =>
     {
         MyViewComponent <AttributesComponent>
         .ShouldHave()
         .Attributes(attributes => attributes
                     .PassingFor <ActionNameAttribute>(authorize => Assert.Equal("Admin", authorize.Name)));
     },
         "When testing AttributesComponent was expected to have ActionNameAttribute, but in fact such was not found.");
 }
 public void AttributesShouldNotThrowEceptionWithControllerContainingNumberOfAttributes()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes(withTotalNumberOf: 2);
 }
 public void AttributesShouldNotThrowEceptionWithControllerContainingAttributes()
 {
     MyViewComponent <AttributesComponent>
     .ShouldHave()
     .Attributes();
 }
 public void NoAttributesShouldNotThrowExceptionWithControllerContainingNoAttributes()
 {
     MyViewComponent <NormalComponent>
     .ShouldHave()
     .NoAttributes();
 }