public void StrongTypeFormatterPerformanceTest() { var strongTypeFormatter = new StrongTypeFormatter(); var testEntity = new ClassForTest(); var watch = Stopwatch.StartNew(); for (int i = 0; i < iterationCount; i++) { var buffer = strongTypeFormatter.Serialize(testEntity); var testEintity = strongTypeFormatter.Deserialize(buffer); } watch.Stop(); Debug.WriteLine($"StrongTypeFormatter result {watch.ElapsedMilliseconds} ms."); BinaryFormatter binary = new BinaryFormatter(); watch = Stopwatch.StartNew(); for (int i = 0; i < iterationCount; i++) { using (MemoryStream mStream = new MemoryStream()) { binary.Serialize(mStream, testEntity); mStream.Position = 0; var testEintity = binary.Deserialize(mStream); } } watch.Stop(); Debug.WriteLine($"BinarySerializer result {watch.ElapsedMilliseconds} ms."); }
public void InvokeExpressionTest5() { Expression <Func <int, int> > rootExpression = x => ClassForTest.GetLength(x.ToString()); var subExpression = ((MethodCallExpression)rootExpression.Body).Arguments[0]; // just the `x.ToString()` part Assert.AreEqual("123", InvokeSubExpression <string>(rootExpression, subExpression, 123)); // we pass root parameter but evaluate the sub-expression only }
public void InvokeExpressionTest4() { Expression <Func <int, int> > rootExpression = x => Math.Abs(x) + ClassForTest.GetLength(x.ToString()); var subExpression = ((BinaryExpression)rootExpression.Body).Right; Assert.AreEqual(3, InvokeSubExpression <int>(rootExpression, subExpression, 123)); // we pass root parameter but evaluate the sub-expression only }
public void TestAppleShouldReturnApple() { // arrange var exceptOutputString = "apple"; ClassForTest Apple = new ClassForTest(); //Act var result = Apple.GetApple(); // assert Assert.Equal(exceptOutputString, result); }
// [InlineData()] public void TestUnitForCountLetterFunction(string source) { Dictionary <char, int> expectOutput = new Dictionary <char, int>() { { 'a', 2 }, { 'b', 2 }, { 'c', 2 }, { 'd', 2 } }; ClassForTest classForTest = new ClassForTest(); Assert.Equal(expectOutput, classForTest.CountLetters(source)); }
public void StrongTypeFormatterClassTest() { var strongTypeFormatter = new StrongTypeFormatter(); var testEntity = new ClassForTest(); var watch = Stopwatch.StartNew(); for (int i = 0; i < iterationCount; i++) { var buffer = strongTypeFormatter.Serialize(testEntity); var testEintity = strongTypeFormatter.Deserialize(buffer); } watch.Stop(); Debug.WriteLine($"StrongTypeFormatter result {watch.ElapsedMilliseconds} ms."); }
public void DynamicFormatterClassTest() { var DynamicFormatter = new DynamicFormatter <ClassForTest>(); var testEntity = new ClassForTest(); var watch = Stopwatch.StartNew(); for (int i = 0; i < iterationCount; i++) { var buffer = DynamicFormatter.Serialize(testEntity); var testEintity = DynamicFormatter.Deserialize(buffer); } watch.Stop(); Debug.WriteLine($"DynamicSerialize result {watch.ElapsedMilliseconds} ms."); }
public void TestSumShouldReturnTheSumForEmpty() { //arrange var exceptSum = 0; List <int> numList = new List <int>(); ClassForTest Sum = new ClassForTest(); // act var result = Sum.Sum(numList); //assert Assert.Equal(exceptSum, result); }
private IEnumerable <Node> InitChildrenForTest() { string ctd = @"<ContentType name=""RuntimeNode"" parentType=""GenericContent"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition""> <DisplayName>RuntimeNode</DisplayName> <Description>Use RuntimeNodes to handle an object.</Description> <Icon>Folder</Icon> <Fields> <Field name=""name"" type=""ShortText""> <DisplayName>Object Name</DisplayName> </Field> <Field name=""counter"" type=""Integer""> <DisplayName>Counter</DisplayName> </Field> <Field name=""ModificationDate"" type=""DateTime""> <DisplayName>Modification Date</DisplayName> <Description>Content was last modified on this date.</Description> <Configuration> <VisibleBrowse>Hide</VisibleBrowse> <VisibleEdit>Hide</VisibleEdit> <VisibleNew>Hide</VisibleNew> <DateTimeMode>DateAndTime</DateTimeMode> </Configuration> </Field> </Fields> </ContentType> "; var nodes = new Node[3]; var objectToEdit = new ClassForTest[nodes.Length]; for (int i = 0; i < nodes.Length; i++) { var name = "MyObjectInstance" + i; objectToEdit[i] = new ClassForTest() { name = name, counter = 123 + i }; var content = Content.Create(objectToEdit[i], ctd); var runtimeCH = (SenseNet.ContentRepository.Content.RuntimeContentHandler)content.ContentHandler; runtimeCH.Name = name; nodes[i] = runtimeCH; } return(nodes); }
public void TestSumShouldReturnTheSumForMutipleElements() { //arrange var exceptSum = 6; List <int> numList = new List <int>() { 1, 2, 3 }; ClassForTest Sum = new ClassForTest(); // act var result = Sum.Sum(numList); //assert Assert.Equal(exceptSum, result); }
public void TestSumShouldReturnTheSumForOneElement() { //arrange var element = 1; var exceptSum = element; List <int> numList = new List <int>() { element }; ClassForTest Sum = new ClassForTest(); // act var result = Sum.Sum(numList); //assert Assert.Equal(exceptSum, result); }
IEnumerable<Node> InitChildrenForTest() { string ctd = @"<ContentType name=""RuntimeNode"" parentType=""GenericContent"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition""> <DisplayName>RuntimeNode</DisplayName> <Description>Use RuntimeNodes to handle an object.</Description> <Icon>Folder</Icon> <Fields> <Field name=""name"" type=""ShortText""> <DisplayName>Object Name</DisplayName> </Field> <Field name=""counter"" type=""Integer""> <DisplayName>Counter</DisplayName> </Field> <Field name=""ModificationDate"" type=""DateTime""> <DisplayName>Modification Date</DisplayName> <Description>Content was last modified on this date.</Description> <Configuration> <VisibleBrowse>Hide</VisibleBrowse> <VisibleEdit>Hide</VisibleEdit> <VisibleNew>Hide</VisibleNew> <DateTimeMode>DateAndTime</DateTimeMode> </Configuration> </Field> </Fields> </ContentType> "; var nodes = new Node[3]; var objectToEdit = new ClassForTest[nodes.Length]; for (int i = 0; i < nodes.Length; i++) { var name = "MyObjectInstance" + i; objectToEdit[i] = new ClassForTest() { name = name, counter = 123 + i }; var content = Content.Create(objectToEdit[i], ctd); var runtimeCH = (SenseNet.ContentRepository.Content.RuntimeContentHandler)content.ContentHandler; runtimeCH.Name = name; nodes[i] = runtimeCH; } return nodes; }
public void TestIsAnagrameShouldTrue(string str1, string str2) { ClassForTest classForTest = new ClassForTest(); Assert.True(classForTest.IsAnagrame(str1, str2)); }
public void TestSumShouldReturnTheSumForNull() { ClassForTest classForTest = new ClassForTest(); Assert.Null(classForTest.Sum(null)); }