public void EndWithTest() { StringAssert.EndsWith("amazon fires", "fires"); }
public void EndsWith() { StringAssert.EndsWith("abc", "abc"); StringAssert.EndsWith("abc", "123abc"); }
public static void ShouldBeSurroundedWith(this string actual, string expectedDelimiter) { StringAssert.StartsWith(expectedDelimiter, actual); StringAssert.EndsWith(expectedDelimiter, actual); }
public void ConstructorShouldSetX64ProcessForX64Architecture() { StringAssert.EndsWith(this.startInfo.FileName, "testhost.exe"); }
public void NombreCompletoTerminaConSegundoNombre() { StringAssert.EndsWith(player.FullName, player.LastName); StringAssert.EndsWith(player.FullName, "Hernandez"); }
public void HaveFullNameEndingWithLastName() { // Assert.IsTrue(sut.FullName.EndsWith("Cosby")); StringAssert.EndsWith(sut.FullName, "Cosby"); }
public void Should_handle_non_capturing_gorups() { var result = RegexSampler.GetRegexSample(@"bla (?:.*) foo (.*) bar", new[] { "p1" }); StringAssert.EndsWith(" foo <p1> bar", result); }
public void VerifyFileWasOpened() { StringAssert.EndsWith("OpenMe.txt", MainScreen.FileName); }
public void TestCreateTableInSchemaAndImportAsTableInfo() { var db = GetCleanedServer(DatabaseType.MicrosoftSQLServer); using (var con = db.Server.GetConnection()) { con.Open(); db.Server.GetCommand("CREATE SCHEMA Omg", con).ExecuteNonQuery(); var tbl = db.CreateTable("Fish", new [] { new DatabaseColumnRequest("MyCol", "int") { IsPrimaryKey = true } }, schema: "Omg"); Assert.AreEqual("Fish", tbl.GetRuntimeName()); Assert.AreEqual("Omg", tbl.Schema); Assert.IsTrue(tbl.GetFullyQualifiedName().EndsWith("Omg.[Fish]")); Assert.IsTrue(tbl.Exists()); TableInfo ti; ColumnInfo[] cols; Import(tbl, out ti, out cols); Assert.AreEqual("Omg", ti.Schema); var tbl2 = ti.Discover(DataAccessContext.InternalDataProcessing); Assert.AreEqual("Omg", tbl2.Schema); Assert.IsTrue(tbl2.Exists()); Assert.IsTrue(ti.Name.EndsWith("Omg.[Fish]")); Assert.IsTrue(ti.GetFullyQualifiedName().EndsWith("Omg.[Fish]")); var c = cols.Single(); Assert.AreEqual("MyCol", c.GetRuntimeName()); StringAssert.Contains("Omg.[Fish]", c.GetFullyQualifiedName()); //should be primary key Assert.IsTrue(c.IsPrimaryKey); var triggerFactory = new TriggerImplementerFactory(DatabaseType.MicrosoftSQLServer); var impl = triggerFactory.Create(tbl); Assert.AreEqual(TriggerStatus.Missing, impl.GetTriggerStatus()); impl.CreateTrigger(new ThrowImmediatelyCheckNotifier()); Assert.AreEqual(TriggerStatus.Enabled, impl.GetTriggerStatus()); Assert.IsTrue(impl.CheckUpdateTriggerIsEnabledAndHasExpectedBody()); //should be synced var sync = new TableInfoSynchronizer(ti); sync.Synchronize(new AcceptAllCheckNotifier()); //Test importing the _Legacy table valued function that should be created in the Omg schema and test synching that too. var tvf = ti.Discover(DataAccessContext.InternalDataProcessing).Database.ExpectTableValuedFunction("Fish_Legacy", "Omg"); Assert.IsTrue(tvf.Exists()); var importerTvf = new TableValuedFunctionImporter(CatalogueRepository, tvf); TableInfo tvfTi; ColumnInfo[] tvfCols; importerTvf.DoImport(out tvfTi, out tvfCols); Assert.AreEqual("Omg", tvfTi.Schema); var syncTvf = new TableInfoSynchronizer(tvfTi); syncTvf.Synchronize(new ThrowImmediatelyCheckNotifier()); StringAssert.EndsWith("Omg.Fish_Legacy(@index) AS Fish_Legacy", tvfTi.Name); } }
public void EndsWithTest() { StringAssert.EndsWith("Unit Testing Tutorial", "Tutorial"); }
public void EndsWith() { StringAssert.EndsWith("Unit Test Practise", "Practise"); }
public void StringEndsWithTest() { StringAssert.EndsWith("string which ends with searched", "Ends with searched"); }
public void StringEndsWith(string value, string substring) { StringAssert.EndsWith(value, substring); }
private static void EndsWithTrimmed(Func <CSharpProperty> propertyFactory, string substring) => StringAssert.EndsWith(Property(propertyFactory).Trim(), substring);
public void EndsWithTest() { StringAssert.EndsWith("Hello misha", "misha"); }
private static bool Assert(string actual, ExpectTo expectsTo, string expected, string message) { expected = expected.TrimEnd(); actual = actual.TrimEnd(); bool r; switch (expectsTo) { case ExpectTo.Contain: r = actual == null && expected == null || actual != null && expected != null && actual.Contains(expected); if (!r && message != null) { StringAssert.Contains(expected, actual, $"{message} - The actual string should contain the expected string."); } return(r); case ExpectTo.EndWith: r = expected == null && actual == null || actual != null && expected != null && actual.EndsWith(expected, StringComparison.Ordinal); if (!r && message != null) { StringAssert.EndsWith(expected, actual, $"{message} - The actual string should end with the expected string."); } return(r); case ExpectTo.Equal: r = expected == actual; if (!r && message != null) { UnitTestingAssert.AreEqual(expected, actual, $"{message} - The actual string should equal to the expected string."); } return(r); case ExpectTo.EqualIgnoringCase: r = string.Equals(expected, actual, StringComparison.InvariantCultureIgnoreCase); if (!r && message != null) { StringAssert.AreEqualIgnoringCase(expected, actual, $"{message}: The actual string does not equal ignoring case to the expected string."); } return(r); case ExpectTo.Match: r = expected == null && actual == null || expected != null && actual != null && Regex.IsMatch(actual, expected); if (!r && message != null) { StringAssert.IsMatch(expected, actual, $"{message} - The actual string should match the expected string pattern."); } return(r); case ExpectTo.NotEndWith: r = (actual == null) != (expected == null) || expected != null && actual != null && !actual.EndsWith(expected, StringComparison.Ordinal); if (!r && message != null) { StringAssert.DoesNotEndWith(expected, actual, $"{message} - The actual string should not end with the expected string."); } return(r); case ExpectTo.NotEqual: r = actual != expected; if (!r && message != null) { UnitTestingAssert.AreNotEqual(expected, actual, $"{message}: The actual string should not equal to the expected string."); } return(r); case ExpectTo.NotEqualIgnoringCase: r = (expected == null) != (actual == null) || expected != null && actual != null && !expected.Equals(actual, StringComparison.OrdinalIgnoreCase); if (!r && message != null) { StringAssert.AreNotEqualIgnoringCase(expected, actual, $"{message} - The actual string should not equal ignoring case to the expected string."); } return(r); case ExpectTo.NotMatch: r = (expected == null) != (actual == null) || expected != null && actual != null && !Regex.IsMatch(actual, expected); if (!r && message != null) { StringAssert.DoesNotMatch(expected, actual, $"{message} - The actual string should not match the expected string."); } return(r); case ExpectTo.NotStartWith: r = (expected == null) != (actual == null) || actual != null && expected != null && !actual.StartsWith(expected, StringComparison.Ordinal); if (!r && message != null) { StringAssert.DoesNotStartWith(expected, actual, $"{message} - The actual string should not start with the expected string."); } return(r); case ExpectTo.StartWith: r = (expected == null) && (actual == null) || actual != null && expected != null && actual.StartsWith(expected, StringComparison.Ordinal); if (!r && message != null) { StringAssert.StartsWith(expected, actual, $"{message} - The actual string should start with the expected string."); } return(r); default: throw new InvalidOperationException($"Expect to {expectsTo} is invalid."); } }
public void Test_DropTableValuedFunction(string schema) { var db = GetTestDatabase(DatabaseType.MicrosoftSQLServer); using (var con = db.Server.GetConnection()) { con.Open(); //create the schema if it doesn't exist yet if (schema != null) { db.Server.GetCommand($@" IF NOT EXISTS ( SELECT * FROM sys.schemas WHERE name = N'{schema}' ) EXEC('CREATE SCHEMA {schema}')", con).ExecuteNonQuery(); } string sql = $@"CREATE FUNCTION {schema}.MyAwesomeFunction ( -- Add the parameters for the function here @startNumber int , @stopNumber int, @name varchar(50) ) RETURNS @ReturnTable TABLE ( -- Add the column definitions for the TABLE variable here Number int, Name varchar(50) ) AS BEGIN -- Fill the table variable with the rows for your result set DECLARE @i int; set @i = @startNumber while(@i < @stopNumber) begin INSERT INTO @ReturnTable(Name,Number) VALUES (@name,@i); set @i = @i + 1; end RETURN END"; db.Server.GetCommand(sql, con).ExecuteNonQuery(); } var tvf = db.DiscoverTableValuedFunctions().Single(); var p = tvf.DiscoverParameters().First(); Assert.AreEqual("@startNumber", p.ParameterName); Assert.AreEqual("int", p.DataType.SQLType); Assert.AreEqual(schema, tvf.Schema ?? "dbo"); StringAssert.EndsWith(".MyAwesomeFunction(@startNumber,@stopNumber,@name)", tvf.GetFullyQualifiedName()); Assert.IsTrue(tvf.Exists()); tvf.Drop(); Assert.IsFalse(tvf.Exists()); }
protected virtual void AssertCacheKeysBasicFormat(string cacheKey) { Assert.IsNotNull(cacheKey); StringAssert.StartsWith(BaseCacheKey, cacheKey, "Key does not start with BaseKey"); StringAssert.EndsWith(mediaType.ToString(), cacheKey, "Key does not end with MediaType"); }
public void Concat06() { MyText txt = new MyText(); StringAssert.EndsWith("!", txt.Concat("Parabéns!", "")); }
public async Task Search() { var MockedClient = new Moq.Mock <IAirTeamHttpClient>(); var htmlParseService = new HtmlParseService(); var MockedCache = new Moq.Mock <IDistributedCache>(); var MockedIOptions = new Moq.Mock <IOptions <AirTeamSetting> >(); var mock = new Mock <ILogger <Controllers.v1.AirTeamController> >(); MockedClient.SetupGet(o => o.BaseUrl).Returns(new Uri("http://test.com")); MockedIOptions.SetupGet(o => o.Value).Returns(new AirTeamSetting { CacheExprationMinutes = 15 }); var actualService = new AirTeamService(MockedCache.Object, MockedClient.Object, htmlParseService, MockedIOptions.Object); var airTeamController = new Controllers.v1.AirTeamController(actualService, mock.Object); var baseDir = AppDomain.CurrentDomain.BaseDirectory; if (baseDir == null) { throw new NullReferenceException("baseDirectory of test app is null"); } var sampleFilePath = Path.Combine(baseDir, "sampleResponse.txt"); string resultHtml = File.ReadAllText(sampleFilePath); var keyword = "777x"; #region get from httpClient var calledHttp = false; MockedClient.Setup(cl => cl.SearchByKeyword(Moq.It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns <string, CancellationToken>((key, token) => { calledHttp = true; return(Task.FromResult(resultHtml)); }); MockedCache.Setup(ca => ca.GetAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns <string, CancellationToken>((key, token) => { return(Task.FromResult <byte[]>(null !)); }); var resultImages = await airTeamController.Search(keyword); Assert.AreEqual(25, resultImages.Count()); Assert.IsTrue(calledHttp); #endregion #region get from cache MockedClient.Setup(cl => cl.SearchByKeyword(Moq.It.IsAny <string>(), It.IsAny <CancellationToken>())).Throws(new InvalidOperationException("Must Use Cache")); var calledCache = false; MockedCache.Setup(ca => ca.GetAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns <string, CancellationToken>((key, token) => { calledCache = true; var bytes = Encoding.UTF8.GetBytes(resultHtml); return(Task.FromResult(bytes)); }); resultImages = await airTeamController.Search(keyword); Assert.AreEqual(25, resultImages.Count()); Assert.IsTrue(calledCache); #endregion #region check result fields var firstItem = resultImages.First(); Assert.AreEqual("353153", firstItem.ImageId); Assert.AreEqual("Boeing 777-9X", firstItem.Title); Assert.IsFalse(string.IsNullOrWhiteSpace(firstItem.DetailUrl)); StringAssert.EndsWith(firstItem.BaseImageUrl, "pics/353/353153_200.jpg"); #endregion }
public static void should_end_with(this string actual, string end) { StringAssert.EndsWith(end, actual); }
public void Relative_FileQueries_Are_Expanded() { FileQuery query = new FileQuery(@"%WINDIR%\system32\..\taskman.exe"); StringAssert.EndsWith(Environment.GetEnvironmentVariable("WINDIR"), query.SearchDir); }
public static void ShouldEndWith(this string value, string substring) { StringAssert.EndsWith(value, substring); }
public void VerifyFileWasSaved() { StringAssert.EndsWith("SaveMe.txt", MainScreen.FileName); }
public void HaveFullNameEndingWithLastName() { StringAssert.EndsWith(sut.FullName, "Smith"); }
internal static void ShouldEndWith(this string actualValue, string expectedValue, string errorMessage = null) { StringAssert.EndsWith(expectedValue, actualValue, errorMessage); }
public static void ShouldEndWith(this string actual, string expected) { StringAssert.EndsWith(expected, actual); }
public void GetXmlFromAssembly_Assembly_XmlElement() { var actual = DocsService.GetXmlFromAssembly(typeof(Stub).Assembly); StringAssert.EndsWith("DocsByReflection.UnitTests.Stubs", actual.SelectSingleNode("//name").InnerText); }
public void TestAssertions() { #region Condition assertions Assert.True(true, "Assert.True and Assert.IsTrue test that the specified condition is true. "); Assert.IsTrue(true); Assert.False(false, "Assert.False and Assert.IsFalse test that the specified condition is false."); Assert.IsFalse(false); Assert.Null(null); Assert.IsNull(null, "Assert.Null and Assert.IsNull test that the specified object is null."); Assert.IsNotNull("10"); Assert.NotNull("10", ""); Assert.IsNaN(Double.NaN, "Assert.IsNaN tests that the specified double value is NaN (Not a number)."); Assert.IsEmpty(""); Assert.IsEmpty(new List <object>()); Assert.IsNotEmpty(new List <object> { 1 }); Assert.IsNotEmpty("MyTestString"); #endregion #region Equality Assert.AreEqual(true, true, "Assert.AreEqual tests whether the two arguments are equal."); Assert.AreNotEqual(true, false); #endregion #region Identity Assert.AreSame(string.Empty, string.Empty, "Assert.AreNotSame tests that the two arguments do not reference the same object."); Assert.AreNotSame(new object(), new object()); //both objects are refering to same object object a = new object(); object b = a; Assert.AreSame(a, b); #endregion #region Comparision //Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. //Thus Assert.Greater(x, y) asserts that x is greater than y (x > y). Assert.Greater(Decimal.MaxValue, Decimal.MinValue, "Assert.Greater tests whether one object is greater than than another"); Assert.GreaterOrEqual(Decimal.MinValue, Decimal.MinValue); Assert.Less(Decimal.MinValue, Decimal.MaxValue); Assert.LessOrEqual(Decimal.MinValue, Decimal.MinValue); #endregion #region Types Assert.IsInstanceOf <decimal>(decimal.MinValue, "Assert.IsInstanceOf succeeds if the object provided as an actual value is an instance of the expected type."); Assert.IsNotInstanceOf <int>(decimal.MinValue); Assert.IsNotAssignableFrom(typeof(List <Type>), string.Empty, "Assert.IsAssignableFrom succeeds if the object provided may be assigned a value of the expected type."); Assert.IsAssignableFrom(typeof(List <decimal>), new List <decimal>()); Assert.IsNotAssignableFrom <List <Type> >(string.Empty); Assert.IsAssignableFrom <List <decimal> >(new List <decimal>()); #endregion #region Strings //The StringAssert class provides a number of methods that are useful when examining string values StringAssert.Contains("london", "london"); StringAssert.StartsWith("Food", "FoodPanda"); StringAssert.EndsWith("rangers", "Powerrangers"); StringAssert.AreEqualIgnoringCase("DOG", "dog"); StringAssert.IsMatch("[10-29]", "15"); StringAssert.DoesNotContain("abc", "defghijk"); StringAssert.DoesNotEndWith("abc", "abcdefgh"); StringAssert.DoesNotMatch("abc", "def"); string a1 = "abc"; string b1 = "abcd"; //StringAssert.ReferenceEquals(a1, b1); need to debug why it's failing Assert.Contains(string.Empty, new List <object> { string.Empty }, "Assert.Contains is used to test whether an object is contained in a collection."); #endregion #region Collections //The CollectionAssert class provides a number of methods that are useful when examining collections and //their contents or for comparing two collections. These methods may be used with any object implementing IEnumerable. //The AreEqual overloads succeed if the corresponding elements of the two collections are equal. //AreEquivalent tests whether the collection contents are equal, but without regard to order. //In both cases, elements are compared using NUnit's default equality comparison. CollectionAssert.AllItemsAreInstancesOfType(new List <decimal> { 0m }, typeof(decimal)); CollectionAssert.AllItemsAreNotNull(new List <decimal> { 0m }); CollectionAssert.AllItemsAreUnique(new List <decimal> { 0m, 1m }); CollectionAssert.AreEqual(new List <decimal> { 0m }, new List <decimal> { 0m }); CollectionAssert.AreEquivalent(new List <decimal> { 0m, 1m }, new List <decimal> { 1m, 0m }); // Same as AreEqual though order does not mater CollectionAssert.AreNotEqual(new List <decimal> { 0m }, new List <decimal> { 1m }); CollectionAssert.AreNotEquivalent(new List <decimal> { 0m, 1m }, new List <decimal> { 1m, 2m }); // Same as AreNotEqual though order does not matter CollectionAssert.Contains(new List <decimal> { 0m, 1m }, 1m); CollectionAssert.DoesNotContain(new List <decimal> { 0m, 1m }, 2m); CollectionAssert.IsSubsetOf(new List <decimal> { 1m }, new List <decimal> { 0m, 1m }); // {1} is considered a SubSet of {1,2} CollectionAssert.IsNotSubsetOf(new List <decimal> { 1m, 2m }, new List <decimal> { 0m, 1m }); CollectionAssert.IsEmpty(new List <decimal>()); CollectionAssert.IsNotEmpty(new List <decimal> { 1m }); CollectionAssert.IsOrdered(new List <decimal> { 1m, 2m, 3m }); CollectionAssert.IsOrdered(new List <string> { "a", "A", "b" }, StringComparer.CurrentCultureIgnoreCase); CollectionAssert.IsOrdered(new List <int> { 3, 2, 1 }, "The list is ordered"); // Only supports ICompare and not ICompare<T> as of version 2.6 #endregion #region File Assert //Various ways to compare a stream or file. //The FileAssert class provides methods for comparing or verifying the existence of files //Files may be provided as Streams, as FileInfos or as strings giving the path to each file. FileAssert.AreEqual(new MemoryStream(), new MemoryStream()); FileAssert.AreEqual(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt")); FileAssert.AreEqual("MyFile.txt", "MyFile.txt"); FileAssert.AreNotEqual(new FileInfo("MyFile.txt"), new FileInfo("MyFile2.txt")); FileAssert.AreNotEqual("MyFile.txt", "MyFile2.txt"); FileAssert.AreNotEqual(new FileStream("MyFile.txt", FileMode.Open), new FileStream("MyFile2.txt", FileMode.Open)); FileAssert.Equals(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt")); FileAssert.ReferenceEquals(new FileInfo("MyFile.txt"), new FileInfo("MyFile.txt")); #endregion #region Utilities // Used to stop test execution and mark them pass or fail or skip if (Convert.ToInt32(DateTime.Now.Second) > 30) { Console.WriteLine("Exaple on Utilities assertions"); Assert.Ignore(); } if (Convert.ToInt32(DateTime.Now.Second) < 30) { Assert.Inconclusive(); } // Defining the failed message Assert.IsTrue(true, "A failed message here"); Assert.Pass(); Assert.Fail(); #endregion }
public void TestGetRemoteDebuggerToolsPath_AppendsExpectedConstant() { string result = _objectUnderTest.GetRemoteDebuggerToolsPath(); StringAssert.EndsWith(result, @"Remote Debugger\x64\*"); }