public void ContainsAttributeTest() { var cm = new CodeMemberMethod(); cm.AddMethodAttribute("You Foo"); Assert.IsTrue(cm.ContainsAttribute("You Foo").Compile().Invoke()); cm.AddMethodAttribute(" ABC"); cm.AddMethodAttribute(" CDE "); cm.AddMethodAttribute("E F G"); Assert.IsTrue(cm.ContainsAttribute("E F G").Compile().Invoke()); Assert.IsTrue(cm.ContainsAttribute(" CDE ").Compile().Invoke()); Assert.IsTrue(cm.ContainsAttribute(" ABC").Compile().Invoke()); Assert.IsTrue(cm.ContainsAttribute("You Foo").Compile().Invoke()); Assert.IsFalse(cm.ContainsAttribute(" aBC").Compile().Invoke()); }
public void ContainsAttributeOnEmptyCommentsShouldThrow() { var cm = new CodeMemberMethod(); Assert.Throws<AssertionException>(() => cm.ContainsAttribute("Bla").Compile().Invoke()); }
public void CreateTestStubForMethodTest() { var method = new CodeMemberMethod(); method.Name = "TheMethodName"; CodeMethodComposer.CreateTestStubForMethod(method); var expectedComment = "TODO: Implement unit test for TheMethodName"; AssertEx.That( method.ContainsComment(expectedComment), "Comment '{0}' not found in: {1}", expectedComment, method.ContainsCommentMsg()); AssertEx.That( method.ContainsAttribute("Test"), "Attribute 'Test' not found in: {0}", method.ContainsAttributeMsg()); AssertEx.That(method.HasReturnTypeOf(typeof(void))); }