public void AddIfNotExists() { var people = RandomData.GeneratePersonCollection <PersonProper>(10); var person = RandomData.GeneratePerson <PersonProper>(); PersonProper nullPerson = null; var comparer = new PersonProperComparer(); PersonProperComparer nullComparer = null; List <PersonProper> nullList = null; // Test Parameters _ = Assert.ThrowsException <ArgumentReadOnlyException>(() => people.AsReadOnly().AddIfNotExists(person)); // TEST Assert.IsFalse(people.AddIfNotExists(nullPerson)); Assert.IsTrue(nullList.AddIfNotExists(person)); Assert.IsFalse(people.AddIfNotExists(nullPerson, nullComparer)); Assert.IsTrue(people.AddIfNotExists(person)); Assert.IsFalse(people.AddIfNotExists(nullPerson)); Assert.IsTrue(people.AddIfNotExists(RandomData.GeneratePerson <PersonProper>(), comparer)); Assert.IsFalse(people.AddIfNotExists(nullPerson, comparer)); }
public void GetTypeDisplayNameTest() { var person = RandomData.GeneratePerson <PersonProper>(); var result = TypeHelper.GetTypeDisplayName(person); Assert.IsTrue(string.Compare(result, "dotNetTips.Spargine.Tester.Models.RefTypes.PersonProper", StringComparison.Ordinal) == 0); result = TypeHelper.GetTypeDisplayName(person, true); Assert.IsTrue(string.Compare(result, "dotNetTips.Spargine.Tester.Models.RefTypes.PersonProper", StringComparison.Ordinal) == 0); result = TypeHelper.GetTypeDisplayName(typeof(int), true, true, true, '-'); Assert.IsTrue(string.Compare(result, "int", StringComparison.Ordinal) == 0); var people = RandomData.GeneratePersonCollection <PersonProper>(5); result = TypeHelper.GetTypeDisplayName(people); Assert.IsTrue(result.Length > 0); result = TypeHelper.GetTypeDisplayName(RandomData.GeneratePerson <Person>()); Assert.IsTrue(result.Length > 0); }
public void DoesObjectEqualInstance02() { var person = RandomData.GeneratePerson <PersonProper>(); var testPerson = RandomData.GeneratePerson <PersonProper>(); Assert.IsFalse(TypeHelper.DoesObjectEqualInstance(person, testPerson)); }
public void FromJson01() { var person = RandomData.GeneratePerson <PersonProper>(); var json = person.ToJson(); Assert.IsNotNull(TypeHelper.FromJson <PersonProper>(json)); }
public void GeneratePersonTest() { var person = RandomData.GeneratePerson <Models.RefTypes.Person>(); Assert.IsNotNull(person); Assert.IsNotNull(person.Address1); Assert.IsNotNull(person.Address2); Assert.IsTrue(person.BornOn > DateTimeOffset.Parse("1/1/1800")); Assert.IsNotNull(person.CellPhone); Assert.IsNotNull(person.City); Assert.IsNotNull(person.Country); Assert.IsNotNull(person.Email); Assert.IsNotNull(person.FirstName); Assert.IsNotNull(person.HomePhone); Assert.IsNotNull(person.Id); Assert.IsNotNull(person.LastName); Assert.IsNotNull(person.PostalCode); Assert.IsNotNull(person.ToString()); }
public override void Setup() { base.Setup(); this._person = RandomData.GeneratePerson <PersonProper>(); this._peopleJson = this._person.ToJson(); }
public void AddLastTest() { var peopleList = RandomData.GeneratePersonCollection <PersonProper>(10); var peopleArray = peopleList.ToArray(); var person = RandomData.GeneratePerson <PersonProper>(); PersonProper nullPerson = null; //Test Parameters _ = Assert.ThrowsException <ArgumentReadOnlyException>(() => peopleList.ToReadOnlyCollection() .AddLast(person)); // Test List Assert.IsFalse(peopleList.AddLast(nullPerson)); Assert.IsTrue(peopleList.Count() == peopleList.Count); Assert.IsTrue(peopleList.AddLast(person)); Assert.IsTrue(peopleList.Last().Equals(person)); // Test Array var result2 = peopleArray.AddLast(person); Assert.IsTrue(result2.Last().Equals(person)); Assert.IsTrue(peopleArray.AddLast(null).Length == peopleArray.Length); }
public void PropertiesToStringTest() { var personProper = RandomData.GeneratePerson <PersonProper>(); var result = personProper.PropertiesToString(false); Assert.IsTrue(result.Length > 300); }
public void PropertiesToNamesAndValuesTest() { var personProper = RandomData.GeneratePerson <PersonProper>(); var result = personProper.PropertiesToDictionary(); Assert.IsTrue(result.Count() > 1); }
public override void Setup() { base.Setup(); this._person = RandomData.GeneratePerson <PersonProper>(); this._personRecord = RandomData.GeneratePersonCollection(count: 1, addressCount: 1).First(); this._peopleJson = this._person.ToJson(); }
public void GetPropertyValues01() { var person = RandomData.GeneratePerson <PersonProper>(); var result = TypeHelper.GetPropertyValues(person); this.Consumer.Consume(result); }
public void HasPropertyTest() { var person = RandomData.GeneratePerson <PersonProper>(); Assert.IsTrue(person.HasProperty("Id")); Assert.IsFalse(person.HasProperty("XXXXXXXXXXXXX")); }
public void StripNullTest() { var person = RandomData.GeneratePerson <PersonProper>(); PersonProper nullPerson = null; Assert.IsFalse(string.IsNullOrEmpty(person.StripNull())); Assert.IsTrue(string.IsNullOrEmpty(nullPerson.StripNull())); }
public void IsNumericTest() { var people = RandomData.GeneratePersonCollection <PersonProper>(10).AsEnumerable(); var person = RandomData.GeneratePerson <PersonProper>(); Assert.IsTrue(people.GetType().IsEnumerable()); Assert.IsFalse(person.GetType().IsEnumerable()); }
public void JsonEqualsTest() { var person1 = RandomData.GeneratePerson <PersonProper>().ToJson(); var person2 = RandomData.GeneratePerson <PersonProper>().ToJson(); Assert.IsTrue(JsonSerializer.JsonEqual(person1, person1)); Assert.IsFalse(JsonSerializer.JsonEqual(person1, person2)); }
public void FirstOrDefaultPredicateAlternate() { var person = RandomData.GeneratePerson <PersonProper>(); var result = base.personProperCollection.FirstOrDefault(p => p.Id == person.Id, person); base.Consumer.Consume(result); }
public void TestDeserializingPersonFromJson() { var person = RandomData.GeneratePerson <PersonProper>(); var json = dotNetTips.Utility.Standard.Serialization.JsonSerializer.Serialize(person); Assert.IsTrue(dotNetTips.Utility.Standard.Serialization.JsonSerializer.Deserialize <PersonProper>(json) != null); }
public void AddFirstToArray() { var people = base.personProperArrayFull.Clone <PersonProper>(); var result = people.AddFirst(RandomData.GeneratePerson <PersonProper>()); base.Consumer.Consume(result); }
public void ContainsAnyTest() { var people = RandomData.GeneratePersonCollection <PersonProper>(10).ToArray(); var person = RandomData.GeneratePerson <PersonProper>(); Assert.IsFalse(people.ContainsAny(person)); Assert.IsTrue(people.ContainsAny(people.Last())); }
public void UpsertDictionaryNew() { var people = base.personProperDictionary; var person = RandomData.GeneratePerson <PersonProper>(); var result = people.Upsert(person.Id, person); base.Consumer.Consume(result); }
public void AddLastToList() { var people = base.personProperCollection.CopyToList(); var person = RandomData.GeneratePerson <PersonProper>(); var result = people.AddLast(person); base.Consumer.Consume(result); }
public void AddTest() { var people = RandomData.GeneratePersonCollection <PersonProper>(10).ToArray(); var person = RandomData.GeneratePerson <PersonProper>(); var result = people.Add(person); Assert.IsTrue(result.Count() == 11); }
public void DoesObjectEqualInstance() { var person1 = RandomData.GeneratePerson <PersonProper>(); var person2 = RandomData.GeneratePerson <PersonProper>(); var result = TypeHelper.DoesObjectEqualInstance(person1, person2); base.Consumer.Consume(result); }
public void AddTest() { var people = new ConcurrentHashSet <PersonProper>(RandomData.GeneratePersonCollection <PersonProper>(100)); var result = people.Add(RandomData.GeneratePerson <PersonProper>()); Assert.IsTrue(result); Assert.IsTrue(people.Count == 101); }
public void FromJsonFile01() { var person = RandomData.GeneratePerson <PersonProper>(); var fileName = Path.Combine(App.ExecutingFolder(), "testjson"); person.ToJsonFile(fileName); Assert.IsNotNull(TypeHelper.FromJsonFile <PersonProper>(fileName)); }
public void PropertiesToStringTest() { var personRecord = RandomData.GeneratePersonCollection(1).First(); var propertiesTest = new PropertiesTest { Id = RandomData.GenerateKey(), PersonProper = RandomData.GeneratePerson <PersonProper>(), PersonRecord = RandomData.GeneratePersonCollection(1).First(), Today = DateTimeOffset.Now, ClosedOn = DateTimeOffset.Now, }; var result = personRecord.PropertiesToString( header: "PersonRecord", keyValueSeparator: ':', sequenceSeparator: ", ", ignoreNulls: true); Assert.IsTrue(result.Length > 1300); Assert.IsTrue(result.Contains("Addresses")); PrintResult(result, nameof(this.PropertiesToStringTest)); result = propertiesTest.PropertiesToString( header: "PersonRecord", keyValueSeparator: ':', sequenceSeparator: ", ", ignoreNulls: true, includeMemberName: false); Assert.IsTrue(result.Length > 1300); Assert.IsTrue(result.Contains("Addresses")); PrintResult(result, nameof(this.PropertiesToStringTest)); var person = RandomData.GeneratePerson <PersonProper>(); result = person.PropertiesToString(header: person.Id); Assert.IsTrue(result.Length > 500); Assert.IsTrue(result.Contains("Address1")); PrintResult(result, nameof(this.PropertiesToStringTest)); var coordinate = RandomData.GenerateCoordinate <CoordinateProper>(); result = coordinate.PropertiesToString(); Assert.IsTrue(result.Length > 50); Assert.IsTrue(result.Contains("X")); PrintResult(result, nameof(this.PropertiesToStringTest)); var personCollection = RandomData.GeneratePersonCollection(5); result = personCollection.PropertiesToString(); Assert.IsTrue(result.Contains("Item")); Assert.IsTrue(result.Length > 6000); }
public void TestSerializingPersonToJson() { var person = RandomData.GeneratePerson <PersonProper>(); var json = dotNetTips.Utility.Standard.Serialization.JsonSerializer.Serialize(person); Debug.WriteLine(json); Assert.IsTrue(string.IsNullOrEmpty(json) == false); }
public void ContainsAnyList() { var people = base.personProperCollection.Take(base.CollectionCount / 10).ToList(); people.Add(RandomData.GeneratePerson <PersonProper>()); var result = base.personProperCollection.ContainsAny(people.ToArray()); base.Consumer.Consume(result); }
public async Task WriteAsyncTest01() { var channel = new ChannelQueue <PersonProper>(); var person = RandomData.GeneratePerson <PersonProper>(); var token = CancellationToken.None; await channel.WriteAsync(person, cancellationToken : token).ConfigureAwait(false); Assert.IsTrue(channel.Count == 1); }
public void ContainsAnyArray() { var people = base.personProperArrayFull.PickRandom(CollectionCount / 2).ToList(); people.Add(RandomData.GeneratePerson <PersonProper>()); var result = base.personProperArrayFull.ContainsAny(people.ToArray()); base.Consumer.Consume(result); }