public void DecodeInvalidTokenWithNoDotsShouldThrowAuthException() { var ex = Assert.Throws <NotifyAuthException>(() => Authenticator.DecodeToken("tokenwithnodots", NOTIFY_SECRET_ID)); Assert.That(ex.Message, Does.Contain("Token must consist of 3 delimited by dot parts")); }
public void ReferenceEqualsFailsWhenUsed() { var ex = Assert.Throws <InvalidOperationException>(() => Assert.ReferenceEquals(string.Empty, string.Empty)); Assert.That(ex.Message, Does.StartWith("Assert.ReferenceEquals should not be used for Assertions")); }
public void ExistsFailsWhenStringIsEmpty() { var ex = Assert.Throws <ArgumentException>(() => FileAssert.Exists(string.Empty)); Assert.That(ex.Message, Does.StartWith("The actual value cannot be an empty string")); }
private static void TestLogicalTree(Type controlType, DependencyProperty property, DependencyPropertyKey propertyKey = null) { var control = (DependencyObject)Activator.CreateInstance(controlType, true); Assert.That(control, Is.Not.Null); { var value = new object(); SetValue(value); { var children = LogicalTreeHelper.GetChildren(control); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } else { Assert.That(children, Does.Contain(value), "Logical children must contain the value."); } } SetValue(null); { var children = LogicalTreeHelper.GetChildren(control); Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } } { var value = new DependencyObject(); SetValue(value); { var children = LogicalTreeHelper.GetChildren(control); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } else { Assert.That(children, Does.Contain(value), "Logical children must contain the value."); } } { var parent = LogicalTreeHelper.GetParent(value); Assert.That(parent, Is.Null, "Dependency-Objects don't support logical parents."); } SetValue(null); { var children = LogicalTreeHelper.GetChildren(control); Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } } { var value = new FrameworkElement(); SetValue(value); { var children = LogicalTreeHelper.GetChildren(control); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } else { Assert.That(children, Does.Contain(value), "Logical children must contain the value."); } } { var parent = LogicalTreeHelper.GetParent(value); if (excludedPropertiesForLogicalChildSupportTest.Contains(property)) { Assert.That(parent, Is.Not.EqualTo(control), "Parent should match."); } else { Assert.That(parent, Is.EqualTo(control), "Parent should match."); } } SetValue(null); { var children = LogicalTreeHelper.GetChildren(control); Assert.That(children, Does.Not.Contain(value), "Logical children must NOT contain the value."); } } void SetValue(object value) { if (propertyKey is null) { control.SetValue(property, value); } else { control.SetValue(propertyKey, value); } } }
public async Task Date(DateOrder order) { var server = StartServer(new ServerContentIntegrationOption { CVarOverrides = { [CCVars.AdminLogsQueueSendDelay.Name] = "0" }, Pool = true }); await server.WaitIdleAsync(); var sEntities = server.ResolveDependency <IEntityManager>(); var sMaps = server.ResolveDependency <IMapManager>(); var sSystems = server.ResolveDependency <IEntitySystemManager>(); var sAdminLogSystem = sSystems.GetEntitySystem <AdminLogSystem>(); var commonGuid = Guid.NewGuid(); var firstGuid = Guid.NewGuid(); var secondGuid = Guid.NewGuid(); await server.WaitPost(() => { var coordinates = GetMainEntityCoordinates(sMaps); var entity = sEntities.SpawnEntity(null, coordinates); sAdminLogSystem.Add(LogType.Unknown, $"{entity:Entity} test log: {commonGuid} {firstGuid}"); }); await Task.Delay(2000); await server.WaitPost(() => { var coordinates = GetMainEntityCoordinates(sMaps); var entity = sEntities.SpawnEntity(null, coordinates); sAdminLogSystem.Add(LogType.Unknown, $"{entity:Entity} test log: {commonGuid} {secondGuid}"); }); await WaitUntil(server, async() => { var commonGuidStr = commonGuid.ToString(); string firstGuidStr; string secondGuidStr; switch (order) { case DateOrder.Ascending: // Oldest first firstGuidStr = firstGuid.ToString(); secondGuidStr = secondGuid.ToString(); break; case DateOrder.Descending: // Newest first firstGuidStr = secondGuid.ToString(); secondGuidStr = firstGuid.ToString(); break; default: throw new ArgumentOutOfRangeException(nameof(order), order, null); } var firstFound = false; var secondFound = false; var both = await sAdminLogSystem.CurrentRoundLogs(new LogFilter { Search = commonGuidStr, DateOrder = order }); foreach (var log in both) { if (!log.Message.Contains(commonGuidStr)) { continue; } if (!firstFound) { Assert.That(log.Message, Does.Contain(firstGuidStr)); firstFound = true; continue; } Assert.That(log.Message, Does.Contain(secondGuidStr)); secondFound = true; break; } return(firstFound && secondFound); }); }
public void DoesNotExistFailsWhenStringIsEmpty() { var ex = Assert.Throws <ArgumentException>(() => DirectoryAssert.DoesNotExist(string.Empty)); Assert.That(ex.Message, Does.StartWith("The actual value cannot be an empty string")); }
public void TestMoreStringConstraints() { Assert.That("Donetsk", Does.Contain("net")); Assert.That("Donetsk", Does.StartWith("Do")); Assert.That("Donetsk", Does.EndWith("sk")); }
public void ReadFromFileMustThrowArgumentExceptionWhenPathContainsOnlyWhitespaces() { var exception = Assert.Throws <ArgumentException>(() => InvokeReadFromFile(" ")); Assert.That(exception.Message, Does.StartWith("Path cannot be null, empty or contain only whitespaces")); }
public void CompositeTypeResolutionWithGlobalMapping() { var csb = new NpgsqlConnectionStringBuilder(ConnectionString) { ApplicationName = nameof(CompositeTypeResolutionWithGlobalMapping), // Prevent backend type caching in TypeHandlerRegistry Pooling = false }; using (var conn = OpenConnection(csb)) { conn.ExecuteNonQuery("CREATE TYPE pg_temp.composite1 AS (x int, some_text text)"); NpgsqlConnection.GlobalTypeMapper.MapComposite <SomeComposite>("composite1"); try { conn.ReloadTypes(); // Resolve type by DataTypeName using (var cmd = new NpgsqlCommand("SELECT @p", conn)) { cmd.Parameters.Add(new NpgsqlParameter { ParameterName = "p", DataTypeName = "composite1", Value = DBNull.Value }); using (var reader = cmd.ExecuteReader()) { reader.Read(); Assert.That(reader.GetDataTypeName(0), Does.StartWith("pg_temp").And.EndWith(".composite1")); Assert.That(reader.IsDBNull(0), Is.True); } } // Resolve type by ClrType (type inference) conn.ReloadTypes(); using (var cmd = new NpgsqlCommand("SELECT @p", conn)) { cmd.Parameters.Add(new NpgsqlParameter { ParameterName = "p", Value = new SomeComposite { X = 8, SomeText = "foo" } }); using (var reader = cmd.ExecuteReader()) { reader.Read(); Assert.That(reader.GetDataTypeName(0), Does.StartWith("pg_temp").And.EndWith(".composite1")); } } // Resolve type by OID (read) conn.ReloadTypes(); using (var cmd = new NpgsqlCommand("SELECT ROW(1, 'foo')::COMPOSITE1", conn)) using (var reader = cmd.ExecuteReader()) { reader.Read(); Assert.That(reader.GetDataTypeName(0), Does.StartWith("pg_temp").And.EndWith(".composite1")); } } finally { NpgsqlConnection.GlobalTypeMapper.UnmapComposite <SomeComposite>("composite1"); } } }
public void SameValueDifferentTypeRegexMatch(object expected, object actual) { var ex = Assert.Throws <AssertionException>(() => Assert.AreEqual(expected, actual)); Assert.That(ex.Message, Does.Match(@"\s*Expected\s*:\s*.*\s*\(.+\)\r?\n\s*But\s*was\s*:\s*.*\s*\(.+\)")); }
public void ConstructorMustThrowsArgumentNullExceptionWhenIoIsNull() { var exception = Assert.Throws <ArgumentNullException>(() => new RunSettingsFileReader(null)); Assert.That(exception.Message, Does.Contain("io")); }
public void FailsOnSinglesOutsideOfUlpTolerance(object value) { var ex = Assert.Throws <AssertionException>(() => Assert.That(value, new EqualConstraint(20000000.0f).Within(1).Ulps)); Assert.That(ex.Message, Does.Contain("+/- 1 Ulps")); }
public async Task DdosProtectionPlanApiTest() { var container = GetCollection(); var name = Recording.GenerateAssetName(NamePrefix); // create DdosProtectionPlan ddosProtectionPlan = await(await container.CreateOrUpdateAsync(WaitUntil.Completed, name, new DdosProtectionPlanData(TestEnvironment.Location))).WaitForCompletionAsync(); Assert.True(await container.ExistsAsync(name)); var ddosProtectionPlanData = ddosProtectionPlan.Data; ValidateCommon(ddosProtectionPlanData, name); Assert.IsEmpty(ddosProtectionPlanData.Tags); // update var data = new DdosProtectionPlanData(TestEnvironment.Location); data.Tags.Add("tag1", "value1"); data.Tags.Add("tag2", "value2"); ddosProtectionPlan = await(await container.CreateOrUpdateAsync(WaitUntil.Completed, name, data)).WaitForCompletionAsync(); ddosProtectionPlanData = ddosProtectionPlan.Data; ValidateCommon(ddosProtectionPlanData, name); Assert.That(ddosProtectionPlanData.Tags, Has.Count.EqualTo(2)); Assert.That(ddosProtectionPlanData.Tags, Does.ContainKey("tag1").WithValue("value1")); Assert.That(ddosProtectionPlanData.Tags, Does.ContainKey("tag2").WithValue("value2")); // get ddosProtectionPlan = await container.GetAsync(name); ddosProtectionPlanData = ddosProtectionPlan.Data; ValidateCommon(ddosProtectionPlanData, name); Assert.That(ddosProtectionPlanData.Tags, Has.Count.EqualTo(2)); Assert.That(ddosProtectionPlanData.Tags, Does.ContainKey("tag1").WithValue("value1")); Assert.That(ddosProtectionPlanData.Tags, Does.ContainKey("tag2").WithValue("value2")); // patch var tags = new Dictionary <string, string>(); tags.Add("tag2", "value2"); ddosProtectionPlan = await ddosProtectionPlan.SetTagsAsync(tags); ddosProtectionPlanData = ddosProtectionPlan.Data; ValidateCommon(ddosProtectionPlanData, name); Assert.That(ddosProtectionPlanData.Tags, Has.Count.EqualTo(1)); Assert.That(ddosProtectionPlanData.Tags, Does.ContainKey("tag2").WithValue("value2")); // list var ddosProtectionPlans = await container.GetAllAsync().ToEnumerableAsync(); Assert.That(ddosProtectionPlans, Has.Count.EqualTo(1)); ddosProtectionPlan = ddosProtectionPlans[0]; ddosProtectionPlanData = ddosProtectionPlan.Data; ValidateCommon(ddosProtectionPlanData, name); Assert.That(ddosProtectionPlanData.Tags, Has.Count.EqualTo(1)); Assert.That(ddosProtectionPlanData.Tags, Does.ContainKey("tag2").WithValue("value2")); // delete await ddosProtectionPlan.DeleteAsync(WaitUntil.Completed); Assert.False(await container.ExistsAsync(name)); ddosProtectionPlans = await container.GetAllAsync().ToEnumerableAsync(); Assert.IsEmpty(ddosProtectionPlans); // list all ddosProtectionPlans = await _subscription.GetDdosProtectionPlansAsync().ToEnumerableAsync(); Assert.IsEmpty(ddosProtectionPlans); }
public void DecodeInvalidTokenShouldThrowAuthException() { var ex = Assert.Throws <NotifyAuthException>(() => Authenticator.DecodeToken(INVALID_TOKEN, NOTIFY_SECRET_ID)); Assert.That(ex.Message, Does.Contain("Invalid signature")); }
public void DoesNotExistFailsWhenStringExists() { var ex = Assert.Throws <AssertionException>(() => DirectoryAssert.DoesNotExist(_goodDir1.ToString())); Assert.That(ex.Message, Does.StartWith(" Expected: not directory exists")); }
public void ReturnsCorrectOscarWins() { Assert.That(_movie.DTO.movieInformation.Awards, Does.Contain("4 Oscars")); }
public void DoesNotExistFailsWhenStringIsNull() { var ex = Assert.Throws <ArgumentNullException>(() => DirectoryAssert.DoesNotExist((string)null)); Assert.That(ex.Message, Does.StartWith("The actual value must be a non-null string or DirectoryInfo")); }
public void ReturnsCorrectNumberOfNominations() { Assert.That(_movie.DTO.movieInformation.Awards, Does.Contain("218 nominations")); }
public void GivenOne_ReturnOneString() { Assert.That(Program.Fizzbuzz(1), Does.Contain("1")); }
public void RuntimeEndsInMinutes() { Assert.That(_movie.DTO.movieInformation.Runtime, Does.EndWith("min")); }
public string AutoBuildTest(SemVer semVer) { Assert.That(SemVerAutoBuild.Instances.Keys, Does.Contain(semVer.autoBuild)); return(semVer.Build); }
public void NullInequalityWithNotNull() { var q = session.Query <AnotherEntityRequired>().Where(o => o.Input != null); Expect(q, Does.Not.Contain("is null").IgnoreCase, InputSet, BothSame, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => null != o.Input); Expect(q, Does.Not.Contain("is null").IgnoreCase, InputSet, BothSame, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => o.InputNullability != AnotherEntityNullability.True); Expect(q, Does.Not.Contain("end is null").IgnoreCase, InputSet, BothSame, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => AnotherEntityNullability.True != o.InputNullability); Expect(q, Does.Not.Contain("end is null").IgnoreCase, InputSet, BothSame, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => "input" != o.Input); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothSame); q = session.Query <AnotherEntityRequired>().Where(o => o.Input != "input"); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothSame); q = session.Query <AnotherEntityRequired>().Where(o => o.Input != o.Output); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => o.Output != o.Input); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => o.Input != o.NullableOutput); Expect(q, Does.Not.Contain("Input is null").IgnoreCase, BothDifferent, InputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != o.Input); Expect(q, Does.Not.Contain("Input is null").IgnoreCase, BothDifferent, InputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequired.Output != o.Input); Expect(q, Does.Not.Contain("Input is null").IgnoreCase, BothDifferent, InputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.Input != o.NullableAnotherEntityRequired.Output); Expect(q, Does.Not.Contain("Input is null").IgnoreCase, BothDifferent, InputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequired.Input != o.Output); Expect(q, Does.Contain("Input is null").IgnoreCase, BothDifferent, OutputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.Output != o.NullableAnotherEntityRequired.Input); Expect(q, Does.Contain("Input is null").IgnoreCase, BothDifferent, OutputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => 3 != o.NullableOutput.Length); Expect(q, Does.Contain("is null").IgnoreCase, InputSet, BothDifferent, BothNull, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput.Length != 3); Expect(q, Does.Contain("is null").IgnoreCase, InputSet, BothDifferent, BothNull, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => 3 != o.Input.Length); Expect(q, Does.Not.Contain("is null").IgnoreCase, InputSet, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => o.Input.Length != 3); Expect(q, Does.Not.Contain("is null").IgnoreCase, InputSet, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => (o.NullableAnotherEntityRequiredId ?? 0) != (o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId ?? 0)); Expect(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => (o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId ?? 0) != (o.NullableAnotherEntityRequiredId ?? 0)); Expect(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.GetValueOrDefault() != o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.GetValueOrDefault()); Expect(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.GetValueOrDefault() != o.NullableAnotherEntityRequiredId.GetValueOrDefault()); Expect(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.HasValue && o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.HasValue && o.NullableAnotherEntityRequiredId.Value != o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.Value); Expect(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.Value != o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.Value && o.NullableAnotherEntityRequiredId.HasValue && o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.HasValue); Expect(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.HasValue && o.NullableAnotherEntityRequiredId.Value != 0); ExpectAll(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.Value != 0 && o.NullableAnotherEntityRequiredId.HasValue); ExpectAll(q, Does.Not.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.HasValue || o.NullableAnotherEntityRequiredId.Value != 0); ExpectAll(q, Does.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequiredId.Value != 0 || o.NullableAnotherEntityRequiredId.HasValue); ExpectAll(q, Does.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != null && o.NullableOutput != "test"); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothDifferent, BothSame, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != "test" && o.NullableOutput != null); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothDifferent, BothSame, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != null || o.NullableOutput != "test"); ExpectAll(q, Does.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != "test" || o.NullableOutput != null); ExpectAll(q, Does.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != "test" && (o.NullableAnotherEntityRequiredId > 0 && o.NullableOutput != null)); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothDifferent, BothSame, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableOutput != null && (o.NullableAnotherEntityRequiredId > 0 && o.NullableOutput != "test")); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothDifferent, BothSame, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => o.NullableAnotherEntityRequired.NullableAnotherEntityRequiredId.Value != o.NullableAnotherEntityRequiredId.Value); Expect(q, Does.Contain("or case").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.RelatedItems.Any(r => r.Output != o.Input)); Expect(q, Does.Not.Contain("Input is null").IgnoreCase.And.Contain("Output is null").IgnoreCase, BothDifferent, InputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.RelatedItems.All(r => r.Output != o.Input)); Expect(q, Does.Not.Contain("Input is null").IgnoreCase.And.Contain("Output is null").IgnoreCase, InputSet, OutputSet, BothDifferent, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.RelatedItems.All(r => r.Output != null && r.Output != o.Input)); Expect(q, Does.Not.Contain("Input is null").IgnoreCase.And.Not.Contain("Output is null").IgnoreCase, BothDifferent, OutputSet); q = session.Query <AnotherEntityRequired>().Where(o => (o.NullableOutput + o.Output) != o.Output); ExpectAll(q, Does.Contain("is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => (o.Input + o.Output) != o.Output); Expect(q, Does.Not.Contain("is null").IgnoreCase, BothSame, BothDifferent); q = session.Query <AnotherEntityRequired>().Where(o => o.Address.Street != o.Output); Expect(q, Does.Contain("Input is null").IgnoreCase, BothDifferent, OutputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.Address.City != o.Output); Expect(q, Does.Contain("Output is null").IgnoreCase, InputSet, BothNull); q = session.Query <AnotherEntityRequired>().Where(o => o.Address.City != null && o.Address.City != o.Output); Expect(q, Does.Not.Contain("Output is null").IgnoreCase); q = session.Query <AnotherEntityRequired>().Where(o => o.Address.Street != null && o.Address.Street != o.NullableOutput); Expect(q, Does.Contain("Output is null").IgnoreCase, InputSet, BothDifferent); Expect(session.Query <Customer>().Where(o => o.CustomerId != null), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <Customer>().Where(o => null != o.CustomerId), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <Customer>().Where(o => o.CustomerId != "test"), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <Customer>().Where(o => "test" != o.CustomerId), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => o.Order.Customer.CustomerId != "test"), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => "test" != o.Order.Customer.CustomerId), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => o.Order.Customer.CompanyName != "test"), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => "test" != o.Order.Customer.CompanyName), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.CreatedBy.CreatedBy.CreatedBy.Name != "test"), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => "test" != o.CreatedBy.CreatedBy.CreatedBy.Name), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.CreatedBy.CreatedBy.Id != 5), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => 5 != o.CreatedBy.CreatedBy.Id), Does.Not.Contain("is null").IgnoreCase); }
public void TestClientResync2() { Assert.That(new[] { ClientResyncMode.DiscardLocalRealm, ClientResyncMode.RecoverLocalRealm }, Does.Contain(_clientResyncMode)); SyncTestHelpers.RunRosTestAsync(async() => { var config = await GetClientResyncConfig(); Exception ex = null; Session.Error += (s, e) => { if (e.Exception.Message != "End of input") { ex = e.Exception; } }; using (var realm = await GetRealmAsync(config)) { var values = realm.All <IntPrimaryKeyWithValueObject>().AsEnumerable().Select(i => i.StringValue).ToArray(); // Verify expected result: // - RecoverLocalRealm: we have 2 objects - "1" and "3". The "2" is lost because the client had uploaded them to the server already. // - DiscardLocalRealm: we have 1 object - "1". The "2" is lost because we restored from backup and the "3" is discarded. switch (_clientResyncMode) { case ClientResyncMode.DiscardLocalRealm: Assert.That(values.Length, Is.EqualTo(1)); Assert.That(values[0], Is.EqualTo("1")); Assert.That(ex, Is.Null); break; case ClientResyncMode.RecoverLocalRealm: Assert.That(values.Length, Is.EqualTo(2)); CollectionAssert.AreEquivalent(values, new[] { "1", "3" }); Assert.That(ex, Is.Null); break; } } }, (int)TimeSpan.FromMinutes(10).TotalMilliseconds); }
public void NullInequality() { string nullVariable = null; string nullVariable2 = null; string notNullVariable = "input"; IQueryable <AnotherEntity> q; // Null literal against itself q = from x in session.Query <AnotherEntity>() where null != null select x; ExpectNone(q); // Null against constants q = from x in session.Query <AnotherEntity>() where null != "value" select x; ExpectAll(q); q = from x in session.Query <AnotherEntity>() where "value" != null select x; ExpectAll(q); // Null against variables q = from x in session.Query <AnotherEntity>() where null != nullVariable select x; ExpectNone(q); q = from x in session.Query <AnotherEntity>() where null != notNullVariable select x; ExpectAll(q); q = from x in session.Query <AnotherEntity>() where nullVariable != null select x; ExpectNone(q); q = from x in session.Query <AnotherEntity>() where notNullVariable != null select x; ExpectAll(q); // Null against columns. q = from x in session.Query <AnotherEntity>() where x.Input != null select x; ExpectInputIsNotNull(q); q = from x in session.Query <AnotherEntity>() where null != x.Input select x; ExpectInputIsNotNull(q); // Variables against variables. q = from x in session.Query <AnotherEntity>() where nullVariable != nullVariable2 select x; ExpectNone(q); q = from x in session.Query <AnotherEntity>() where nullVariable != notNullVariable select x; ExpectAll(q); q = from x in session.Query <AnotherEntity>() where notNullVariable != nullVariable select x; ExpectAll(q); // Variables against columns. q = from x in session.Query <AnotherEntity>() where nullVariable != x.Input select x; ExpectInputIsNotNull(q); q = from x in session.Query <AnotherEntity>() where notNullVariable != x.Input select x; Expect(q, BothSame, BothNull, OutputSet); q = from x in session.Query <AnotherEntity>() where x.Input != nullVariable select x; ExpectInputIsNotNull(q); q = from x in session.Query <AnotherEntity>() where x.Input != notNullVariable select x; Expect(q, BothSame, OutputSet, BothNull); // Columns against columns q = from x in session.Query <AnotherEntity>() where x.Input != x.Output select x; Expect(q, BothDifferent, InputSet, OutputSet); Expect(session.Query <OrderLine>().Where(o => o.Order.Customer.ContactName != null), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => null != o.Order.Customer.ContactName), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => o.Order.Customer.ContactName != "test"), Does.Contain("is null").IgnoreCase); Expect(session.Query <OrderLine>().Where(o => "test" != o.Order.Customer.ContactName), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => null != o.Component.Property1), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.Component.Property1 != null), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => "test" != o.Component.Property1), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.Component.Property1 != "test"), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => null != o.Component.OtherComponent.OtherProperty1), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.Component.OtherComponent.OtherProperty1 != null), Does.Not.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => "test" != o.Component.OtherComponent.OtherProperty1), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.Component.OtherComponent.OtherProperty1 != "test"), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.CreatedBy.ModifiedBy.CreatedBy.Name != "test"), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => "test" != o.CreatedBy.ModifiedBy.CreatedBy.Name), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.CreatedBy.CreatedBy.Component.OtherComponent.OtherProperty1 != "test"), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => "test" != o.CreatedBy.CreatedBy.Component.OtherComponent.OtherProperty1), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.ModifiedBy.CreatedBy.Id != 5), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => 5 != o.ModifiedBy.CreatedBy.Id), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => o.CreatedBy.ModifiedBy.Id != 5), Does.Contain("is null").IgnoreCase); Expect(session.Query <User>().Where(o => 5 != o.CreatedBy.ModifiedBy.Id), Does.Contain("is null").IgnoreCase); if (Sfi.Dialect is FirebirdDialect) { return; } Expect(db.NumericEntities.Where(o => o.NullableShort != o.NullableShort), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.Short != o.Short), WithoutIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.NullableShort != o.Short), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.Short != o.NullableShort), WithIsNullAndWithoutCast()); short value = 3; Expect(db.NumericEntities.Where(o => o.NullableShort != value), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => value != o.NullableShort), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.NullableShort.Value != value), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => value != o.NullableShort.Value), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.Short != value), WithoutIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => value != o.Short), WithoutIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.NullableShort != 3L), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => 3 != o.NullableShort), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.NullableShort.Value != 3L), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => 3L != o.NullableShort.Value), WithIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => o.Short != 3L), WithoutIsNullAndWithoutCast()); Expect(db.NumericEntities.Where(o => 3L != o.Short), WithoutIsNullAndWithoutCast()); }
public void AssertMultipleErrorTests(string methodName, params string[] assertionMessageRegex) { ITestResult result = CheckResult(methodName, ResultState.Error, assertionMessageRegex); Assert.That(result.Message, Does.StartWith("System.Exception : Simulated Error"));// }
private IResolveConstraint WithIsNullAndWithoutCast() { return(Does.Contain("is null").IgnoreCase.And.Not.Contain("cast").IgnoreCase); }
public void ExistsFailsWhenStringDoesNotExist() { var ex = Assert.Throws <AssertionException>(() => FileAssert.Exists(BAD_FILE)); Assert.That(ex.Message, Does.StartWith(" Expected: file exists")); }
public void ExistsFailsWhenStringDoesNotExist() { var ex = Assert.Throws <AssertionException>(() => DirectoryAssert.Exists(BAD_DIRECTORY)); Assert.That(ex.Message, Does.StartWith(" Expected: directory exists")); }
public void DoesNotExistFailsWhenFileInfoIsNull() { var ex = Assert.Throws <ArgumentNullException>(() => FileAssert.DoesNotExist((FileInfo)null)); Assert.That(ex.Message, Does.StartWith("The actual value must be a non-null string or FileInfo")); }
public void CreateTokenWithInvalidServiceIdThrowsAuthException() { var ex = Assert.Throws <NotifyAuthException>(() => Authenticator.CreateToken(NOTIFY_SECRET_ID, "invalid service id")); Assert.That(ex.Message, Does.Contain("Invalid secret or serviceId. Please check that your API Key is correct")); }