Beispiel #1
0
        public void Primitives()
        {
            var source = new Tuple <int, string, int, int, int, int, int, Tuple <int> >(
                RandGen.GenerateInt(),
                RandGen.GenerateString(10),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                new Tuple <int>(RandGen.GenerateInt()));

            var target = GetClone(source, 2);

            Assert.Equal(source, target);
            Assert.NotSame(source, target);
            Assert.Equal(source.Item1, target.Item1);
            Assert.Equal(source.Item2, target.Item2);
            Assert.Same(source.Item2, target.Item2);
            Assert.Equal(source.Item3, target.Item3);
            Assert.Equal(source.Item4, target.Item4);
            Assert.Equal(source.Item5, target.Item5);
            Assert.Equal(source.Item6, target.Item6);
            Assert.Equal(source.Item7, target.Item7);
            Assert.Equal(source.Rest, target.Rest);
            Assert.NotSame(source.Rest, target.Rest);
        }
Beispiel #2
0
        public virtual void InheritList_Class()
        {
            var source = new Helper3 <Helper1>()
            {
                PropOne = RandGen.GenerateInt()
            };

            for (int i = 0; i < 1000; i++)
            {
                source.Add(new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                });
            }
            ;

            var target = GetClone(source, 1001);

            Assert.NotSame(source, target);
            Assert.Equal(target.Count, source.Count);
            Assert.Equal(target.PropOne, source.PropOne);

            for (int i = 0; i < target.Count; i++)
            {
                Assert.NotSame(target[i], source[i]);
                Assert.Equal(target[i].PropOne, source[i].PropOne);
            }
        }
Beispiel #3
0
        public virtual void DictionaryOfClasses()
        {
            Dictionary <Helper1, Helper1> source = new Dictionary <Helper1, Helper1>();

            for (int i = 0; i < 1000; i++)
            {
                source.Add(new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                },
                           new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                });
            }

            var dest = GetClone(source, 2001);

            Assert.NotNull(dest);
            Assert.Equal(dest.Count, source.Count);

            var destKeys     = dest.Keys.ToList();
            var destValues   = dest.Values.ToList();
            var sourceKeys   = source.Keys.ToList();
            var sourceValues = source.Values.ToList();

            for (int i = 0; i < dest.Keys.Count; i++)
            {
                Assert.NotSame(destKeys[i], sourceKeys[i]);
                Assert.Equal(destKeys[i].PropOne, sourceKeys[i].PropOne);

                Assert.NotSame(destValues[i], sourceValues[i]);
                Assert.Equal(destValues[i].PropOne, sourceValues[i].PropOne);
            }
        }
Beispiel #4
0
        public void IRealOnlyList_Interface()
        {
            IReadOnlyList <MyTmpInterface> source = new List <MyTmpInterface>()
            {
                new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                },
                new Helper1_1()
                {
                    PropOne = RandGen.GenerateInt()
                },
                new HelperStruct3()
                {
                    PropOne = RandGen.GenerateInt()
                }
            };

            var dest = GetClone(source, 3);

            Assert.NotNull(dest);
            Assert.NotSame(dest, source);

            Assert.IsAssignableFrom <Helper1>(dest[0]);
            Assert.IsAssignableFrom <Helper1_1>(dest[1]);
            Assert.IsAssignableFrom <HelperStruct3>(dest[2]);

            Assert.Equal(source[0].PropOne, dest[0].PropOne);
            Assert.Equal(source[1].PropOne, dest[1].PropOne);
            Assert.Equal(source[2].PropOne, dest[2].PropOne);
        }
Beispiel #5
0
        public virtual void ListOfClasses()
        {
            List <Helper2> source = new List <Helper2>();

            for (int i = 0; i < 1000; i++)
            {
                source.Add(new Helper2()
                {
                    Helper = new Helper1()
                    {
                        PropOne = RandGen.GenerateInt()
                    }
                });
            }

            List <Helper2> dest = GetClone(source, 2001);

            Assert.NotNull(dest);
            Assert.Equal(dest.Count, source.Count);

            for (int i = 0; i < dest.Count; i++)
            {
                Assert.NotSame(dest[i], source[i]);
                Assert.NotSame(dest[i].Helper, source[i].Helper);
                Assert.Equal(dest[i].Helper.PropOne, source[i].Helper.PropOne);
            }
        }
Beispiel #6
0
        public void Struct_AsInterface()
        {
            MyTmpInterface source = new HelperStruct3()
            {
                PropOne = RandGen.GenerateInt()
            };

            var dest = GetClone(source, 0);

            Assert.NotNull(dest);
            Assert.Equal(source.PropOne, dest.PropOne);
        }
Beispiel #7
0
        public void Setup()
        {
            _intArray  = new[] { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            _byteArray = RandGen.GenerateByteArray(1000);

            _stringArray = Enumerable
                           .Range(0, 10)
                           .Select(x => RandGen.GenerateString(10))
                           .ToArray();

            _timeSpanArray = Enumerable
                             .Range(0, 10)
                             .Select(x => new TimeSpan(x))
                             .ToArray();

            _dateTimeArray = Enumerable
                             .Range(0, 10)
                             .Select(x => DateTime.Now)
                             .ToArray();

            Func <string> func = () =>
            {
                return(string.Empty);
            };

            _delegateArray = Enumerable
                             .Range(0, 10)
                             .Select(x => func)
                             .ToArray();

            _arrayOfStringArrays = new string[][]
            {
                new string [] { "one", "two" },
                new string [] { "three", "four" }
            };

            _arrayOfClasses = Enumerable
                              .Range(0, 100)
                              .Select(x => new Helper1()
            {
                PropOne = RandGen.GenerateInt()
            })
                              .ToArray();

            _arrayOfStructs = Enumerable
                              .Range(0, 100)
                              .Select(x => new HelperStruct1()
            {
                PropOne = RandGen.GenerateInt()
            })
                              .ToArray();
        }
Beispiel #8
0
        public void SimpleStruct()
        {
            HelperStruct2 source = new HelperStruct2()
            {
                Helper = new HelperStruct1()
                {
                    PropOne = RandGen.GenerateInt()
                }
            };

            HelperStruct2 target = GetClone(source, 0);

            Assert.Equal(source, target);
            Assert.Equal(source.Helper.PropOne, target.Helper.PropOne);
        }
Beispiel #9
0
 public void Setup()
 {
     _readOnlyListString    = RandGen.GenerateStringList(1000, 5);
     _grandChildAsInterface = GrandChildClassHelper.Generate();
     _readOnlyListInterface = new List <MyTmpInterface>()
     {
         new Helper1()
         {
             PropOne = RandGen.GenerateInt()
         },
         new Helper1_1()
         {
             PropOne = RandGen.GenerateInt()
         },
     };
 }
Beispiel #10
0
        public virtual void SimpleClass()
        {
            Helper2 source = new Helper2()
            {
                Helper = new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                }
            };

            Helper2 dest = GetClone(source, 2);

            Assert.NotNull(dest);
            Assert.NotNull(dest.Helper);
            Assert.NotSame(dest.Helper, source.Helper);
            Assert.Equal(dest.Helper.PropOne, source.Helper.PropOne);
        }
Beispiel #11
0
        public virtual void ListOfStructs()
        {
            List <HelperStruct2> source = new List <HelperStruct2>()
            {
                new HelperStruct2()
                {
                    Helper = new HelperStruct1()
                    {
                        PropOne = RandGen.GenerateInt()
                    }
                }
            };

            var dest = GetClone(source, 1);

            Assert.NotNull(dest);
            Assert.Equal(source.Count, dest.Count);
            Assert.Equal(source[0].Helper.PropOne, dest[0].Helper.PropOne);
        }
Beispiel #12
0
        public virtual void DictionaryOfPrimitives()
        {
            Dictionary <int, int> source = new Dictionary <int, int>();

            for (int i = 0; i < 1000; i++)
            {
                source.Add(i, RandGen.GenerateInt());
            }

            var dest = GetClone(source, 1);

            Assert.NotNull(dest);
            Assert.Equal(dest.Count, source.Count);

            foreach (var key in dest.Keys)
            {
                Assert.Equal(dest[key], source[key]);
            }
        }
Beispiel #13
0
        public void InheritList_Struct()
        {
            var source = new Helper3 <HelperStruct1>()
            {
                new HelperStruct1()
                {
                    PropOne = RandGen.GenerateInt()
                }
            };

            source.PropOne = RandGen.GenerateInt();

            var target = GetClone(source, 1);

            Assert.NotSame(source, target);
            Assert.Equal(source.Count, target.Count);
            Assert.Equal(source[0], target[0]);
            Assert.Equal(source[0].PropOne, target[0].PropOne);
            Assert.Equal(source.PropOne, target.PropOne);
        }
Beispiel #14
0
        public virtual void InheritList_Int()
        {
            var source = new Helper3 <int>();

            for (int i = 0; i < 1000; i++)
            {
                source.Add(RandGen.GenerateInt());
            }
            ;

            var target = GetClone(source, 1);

            Assert.NotSame(source, target);
            Assert.Equal(target.Count, source.Count);

            for (int i = 0; i < target.Count; i++)
            {
                Assert.Equal(target[i], source[i]);
            }
        }
Beispiel #15
0
        public void Setup()
        {
            _complexStruct = new HelperStruct2()
            {
                Helper = new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                }
            };

            _simpleStruct = new HelperStruct1()
            {
                PropOne   = RandGen.GenerateInt(),
                PropTwo   = RandGen.GenerateInt(),
                PropThree = RandGen.GenerateInt()
            };

            _nullStruct = default;
        }
Beispiel #16
0
        public virtual void PolymorphicSupport()
        {
            Message source = new Message()
            {
                aRef = new Derived()
                {
                    iBase    = RandGen.GenerateInt(),
                    iDerived = RandGen.GenerateInt()
                }
            };

            var dest = GetClone(source, 2);

            Assert.NotNull(dest);
            Assert.NotNull(dest.aRef);
            Assert.NotSame(dest, source);
            Assert.NotSame(dest.aRef, source.aRef);
            Assert.Equal(dest.aRef.iBase, source.aRef.iBase);

            Assert.IsType <Derived>(source.aRef);
            Assert.IsType <Derived>(dest.aRef);
        }
Beispiel #17
0
        public void ArrayOfClasses()
        {
            Helper1[] source = new Helper1[1000];

            for (int i = 0; i < source.Length; i++)
            {
                source[i] = new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                };
            }

            var dest = GetClone(source, 1001);

            Assert.NotNull(dest);
            Assert.Equal(dest.Length, source.Length);

            for (int i = 0; i < dest.Length; i++)
            {
                Assert.NotSame(dest[i], source[i]);
                Assert.Equal(dest[i].PropOne, source[i].PropOne);
            }
        }
Beispiel #18
0
        public virtual void DictionaryOfStructs()
        {
            Dictionary <HelperStruct1, HelperStruct1> source = new Dictionary <HelperStruct1, HelperStruct1>();

            for (int i = 0; i < 1000; i++)
            {
                source.Add(new HelperStruct1()
                {
                    PropOne = RandGen.GenerateInt() + i
                },
                           new HelperStruct1()
                {
                    PropOne = RandGen.GenerateInt() + i
                });
            }

            var dest = GetClone(source, 1);

            Assert.NotNull(dest);
            Assert.Equal(dest.Count, source.Count);

            var destKeys     = dest.Keys.ToList();
            var destValues   = dest.Values.ToList();
            var sourceKeys   = source.Keys.ToList();
            var sourceValues = source.Values.ToList();

            for (int i = 0; i < dest.Keys.Count; i++)
            {
                Assert.True(source.ContainsKey(destKeys[i]));
                Assert.True(dest.ContainsKey(sourceKeys[i]));

                Assert.Equal(destKeys[i].PropOne, sourceKeys[i].PropOne);
                Assert.Equal(destValues[i], sourceValues[i]);
                Assert.Equal(destValues[i].PropOne, sourceValues[i].PropOne);
            }
        }
Beispiel #19
0
 protected override ItemGenerator <int?> GetItemGenerator()
 {
     return(new ItemGenerator <int?>(() => RandGen.GenerateInt(), new EqualityComparer()));
 }
Beispiel #20
0
        public void Setup()
        {
            _null = null;

            _primitives = new Tuple <int, string, int, int, int, int, int, Tuple <int> >(
                RandGen.GenerateInt(),
                RandGen.GenerateString(10),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                RandGen.GenerateInt(),
                new Tuple <int>(RandGen.GenerateInt()));

            _classes = new Tuple <Helper1, Helper1, Helper1, Helper1, Helper1, Helper1, Helper1, Tuple <Helper1> >(
                new Helper1()
            {
                PropOne = 1
            },
                new Helper1()
            {
                PropOne = 2
            },
                new Helper1()
            {
                PropOne = 3
            },
                new Helper1()
            {
                PropOne = 4
            },
                new Helper1()
            {
                PropOne = 5
            },
                new Helper1()
            {
                PropOne = 6
            },
                new Helper1()
            {
                PropOne = 7
            },
                new Tuple <Helper1>(new Helper1()
            {
                PropOne = 8
            }));

            _structs = new Tuple <HelperStruct1, HelperStruct1, HelperStruct1, HelperStruct1, HelperStruct1, HelperStruct1, HelperStruct1, Tuple <HelperStruct1> >(
                new HelperStruct1()
            {
                PropOne = 1
            },
                new HelperStruct1()
            {
                PropOne = 2
            },
                new HelperStruct1()
            {
                PropOne = 3
            },
                new HelperStruct1()
            {
                PropOne = 4
            },
                new HelperStruct1()
            {
                PropOne = 5
            },
                new HelperStruct1()
            {
                PropOne = 6
            },
                new HelperStruct1()
            {
                PropOne = 7
            },
                new Tuple <HelperStruct1>(new HelperStruct1()
            {
                PropOne = 8
            }));

            var helper = new Tuple <Helper1, Helper1, Helper1, Helper1, Helper1, Helper1, Helper1, Tuple <Helper1> >(
                new Helper1(),
                new Helper1(),
                new Helper1(),
                new Helper1(),
                new Helper1(),
                new Helper1(),
                new Helper1(),
                new Tuple <Helper1>(new Helper1()));

            _duplicates = new List <Tuple <Helper1, Helper1, Helper1, Helper1, Helper1, Helper1, Helper1, Tuple <Helper1> > >();

            for (int i = 0; i < 10000; i++)
            {
                _duplicates.Add(helper);
            }
        }
Beispiel #21
0
 public void Setup()
 {
     _nullableInt = RandGen.GenerateInt();
     _nullInt     = null;
     _struct      = new HelperStruct1();
 }
Beispiel #22
0
 protected override int?GenerateItem() => RandGen.GenerateInt();
Beispiel #23
0
        public void Setup()
        {
            _int = RandGen.GenerateInt();

            _string = RandGen.GenerateString(100);

            _listOfStrings = RandGen.GenerateStringList(1000, 5);

            _listOfBytes = RandGen
                           .GenerateByteArray(100000000)
                           .ToList();

            _listOfInts = RandGen.GenerateIntList(1000);

            _listOfTimeSpans = new List <TimeSpan>()
            {
                new TimeSpan(0),
                new TimeSpan(1),
                new TimeSpan(2),
                new TimeSpan(3),
                new TimeSpan(4),
                new TimeSpan(5),
                new TimeSpan(6),
                new TimeSpan(7),
                new TimeSpan(8),
                new TimeSpan(9),
            };

            _listOfDateTimes = new List <DateTime>()
            {
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
                DateTime.Now,
            };

            Func <string> func = () =>
            {
                return(string.Empty);
            };

            _listOfDelegates = new List <Func <string> >()
            {
                func,
                func,
                func,
                func,
                func,
                func,
                func,
                func,
                func,
                func,
            };
        }
Beispiel #24
0
        public void Setup()
        {
            _null = null;

            _simpleClass = new Helper1()
            {
                PropOne   = RandGen.GenerateInt(),
                PropTwo   = RandGen.GenerateInt(),
                PropThree = RandGen.GenerateInt(),
            };

            _complexClass = new Helper2()
            {
                Helper = new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt(),
                    PropFour  = RandGen.GenerateInt(),
                    PropFive  = RandGen.GenerateInt(),
                    PropSix   = RandGen.GenerateInt(),
                    PropSeven = RandGen.GenerateInt(),
                    PropEight = RandGen.GenerateInt(),
                    PropNine  = RandGen.GenerateInt(),
                    PropTen   = RandGen.GenerateInt()
                }
            };

            _inheritListClass = new Helper3 <Helper1>()
            {
                PropOne = RandGen.GenerateInt()
            };

            for (int i = 0; i < 10000; i++)
            {
                _inheritListClass.Add(new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                });
            }
            ;

            _inheritListInt = new Helper3 <int>();

            for (int i = 0; i < 10000; i++)
            {
                _inheritListInt.Add(RandGen.GenerateInt());
            }
            ;

            _grandChildClass = GrandChildClassHelper.Generate();

            _listSimpleClasses = new List <Helper1>();

            for (int i = 0; i < 10000; i++)
            {
                _listSimpleClasses.Add(new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt(),
                });
            }

            _listComplexClasses = new List <Helper2>();

            for (int i = 0; i < 10000; i++)
            {
                _listComplexClasses.Add(new Helper2()
                {
                    Helper = new Helper1()
                    {
                        PropOne   = RandGen.GenerateInt(),
                        PropTwo   = RandGen.GenerateInt(),
                        PropThree = RandGen.GenerateInt(),
                    }
                });
            }

            _listInterfaces = new List <MyTmpInterface>();

            for (int i = 0; i < 10000; i++)
            {
                _listInterfaces.Add(new Helper1());
                _listInterfaces.Add(new Helper1_1());
            }

            _listSimpleStructs = new List <HelperStruct1>();

            for (int i = 0; i < 10000; i++)
            {
                _listSimpleStructs.Add(new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt(),
                });
            }

            _listComplexStructs = new List <HelperStruct2>();

            for (int i = 0; i < 10000; i++)
            {
                _listComplexStructs.Add(new HelperStruct2()
                {
                    Helper = new HelperStruct1()
                    {
                        PropOne   = RandGen.GenerateInt(),
                        PropTwo   = RandGen.GenerateInt(),
                        PropThree = RandGen.GenerateInt(),
                    }
                });
            }

            _dictOfStructs = new Dictionary <HelperStruct1, HelperStruct1>();

            for (int i = 0; i < 10000; i++)
            {
                _dictOfStructs.Add(
                    new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                },
                    new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                });
            }

            _dictOfClasses = new Dictionary <Helper1, Helper1>();

            for (int i = 0; i < 10000; i++)
            {
                _dictOfClasses.Add(
                    new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                },
                    new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                });
            }

            _dictOfInt = new Dictionary <int, int>();

            for (int i = 0; i < 10000; i++)
            {
                _dictOfInt.Add(i, RandGen.GenerateInt());
            }

            _listSimpleClassesAsInterfaces = _listSimpleClasses
                                             .OfType <MyTmpInterface>()
                                             .ToList();

            _listSimpleClassesAsObjects = _listSimpleClasses
                                          .Cast <object>()
                                          .ToList();
        }