/// <summary>
        /// Appends the given item to the end of the collection.
        /// </summary>
        /// <param name="item">The ErrorItem to be added to the collection.</param>
        public void Add(ErrorItem item)
        {
            UiExceptionHelper.CheckNotNull(item, "item");
            _items.Add(item);

            return;
        }
        public void Test_MethodName()
        {
            ErrorItem item;

            // test to pass

            item = new ErrorItem("path", "namespace1.class.fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo("class"));

            item = new ErrorItem("path", ".class.fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo("class"));

            item = new ErrorItem("path", "0123456789012.a()", 1);
            Assert.That(item.MethodName, Is.EqualTo("a()"));
            Assert.That(item.BaseMethodName, Is.EqualTo("a"));
            Assert.That(item.ClassName, Is.EqualTo("0123456789012"));                

            // test to fail

            item = new ErrorItem("path", "fullMethodName(string arg)", 1);
            Assert.That(item.MethodName, Is.EqualTo("fullMethodName(string arg)"));
            Assert.That(item.BaseMethodName, Is.EqualTo("fullMethodName"));
            Assert.That(item.ClassName, Is.EqualTo(""));

            item = new ErrorItem("path", "", 1);
            Assert.That(item.MethodName, Is.EqualTo(""));
            Assert.That(item.BaseMethodName, Is.EqualTo(""));
            Assert.That(item.ClassName, Is.EqualTo(""));

            return;
        }
Пример #3
0
        /// <summary>
        /// Appends the given item to the end of the collection.
        /// </summary>
        /// <param name="item">The ErrorItem to be added to the collection.</param>
        public void Add(ErrorItem item)
        {
            UiExceptionHelper.CheckNotNull(item, "item");
            _items.Add(item);

            return;
        }
        public void SetUp()
        {
            _items = new InternalTraceItemCollection();

            _resourceA = new TestResource("HelloWorld.txt");
            _resourceB = new TestResource("TextCode.txt");

            _itemA = new ErrorItem(_resourceA.Path, 1);
            _itemB = new ErrorItem(_resourceB.Path, 2);

            return;
        }
Пример #5
0
        public override bool Equals(object obj)
        {
            ErrorItem item = obj as ErrorItem;

            if (item == null)
            {
                return(false);
            }

            return(_path == item._path &&
                   _fullyQualifiedMethodName == item._fullyQualifiedMethodName &&
                   _line == item._line);
        }
        public void Ctor_2()
        {
            ErrorItem item;
            
            item = new ErrorItem("Test.cs", "myFunction()", 1);

            Assert.That(item.Path, Is.EqualTo("Test.cs"));
            Assert.That(item.FullyQualifiedMethodName, Is.EqualTo("myFunction()"));            
            Assert.That(item.LineNumber, Is.EqualTo(1));
            Assert.That(item.HasSourceAttachment, Is.True);
            Assert.That(item.FileExtension, Is.EqualTo("cs"));

            item = new ErrorItem(null, "myFunction()", 1);
            Assert.That(item.Path, Is.Null);
            Assert.That(item.FileExtension, Is.Null);
            Assert.That(item.FullyQualifiedMethodName, Is.EqualTo("myFunction()"));
            Assert.That(item.LineNumber, Is.EqualTo(1));
            Assert.That(item.HasSourceAttachment, Is.False);

            return;
        }
Пример #7
0
        public void Can_Set_Properties()
        {
            ErrorItem item;

            item = new ErrorItem("/dir/file.txt", 13);

            Assert.That(item.FileName, Is.EqualTo("file.txt"));
            Assert.That(item.FileExtension, Is.EqualTo("txt"));
            Assert.That(item.Path, Is.EqualTo("/dir/file.txt"));
            Assert.That(item.LineNumber, Is.EqualTo(13));
            Assert.That(item.HasSourceAttachment, Is.True);

            item = new ErrorItem();
            Assert.That(item.FileName, Is.Null);
            Assert.That(item.FileExtension, Is.Null);
            Assert.That(item.Path, Is.Null);
            Assert.That(item.LineNumber, Is.EqualTo(0));
            Assert.That(item.HasSourceAttachment, Is.False);

            return;
        }
        public void Test_Equals()
        {
            ErrorItem itemA;
            ErrorItem itemB;
            ErrorItem itemC;

            itemA = new ErrorItem("file1.txt", 43);
            itemB = new ErrorItem("file2.txt", 44);
            itemC = new ErrorItem("file1.txt", "myFunction()", 43);

            Assert.That(itemA.Equals(null), Is.False);
            Assert.That(itemA.Equals("hello"), Is.False);
            Assert.That(itemA.Equals(itemB), Is.False);
            Assert.That(itemA.Equals(itemC), Is.False);
            Assert.That(itemA.Equals(itemA), Is.True);
            Assert.That(itemA.Equals(new ErrorItem("file", 43)), Is.False);
            Assert.That(itemA.Equals(new ErrorItem("file1.txt", 42)), Is.False);
            Assert.That(itemA.Equals(new ErrorItem("file1.txt", 43)), Is.True);

            return;
        }
        public void ReadFile()
        {
            ErrorItem item;

            using (new TestResource("HelloWorld.txt"))
            {
                item = new ErrorItem("HelloWorld.txt", 1);

                Assert.That(item.ReadFile(), Is.Not.Null);
                Assert.That(item.ReadFile(), Is.EqualTo("Hello world!"));
            }

            return;
        }        
 public void ReadFile_Throws_FileNotExistException()
 {
     ErrorItem item = new ErrorItem("C:\\unknown\\unknown.txt", 1);
     item.ReadFile(); // throws exception
 }
        public void Test_FileExtension()
        {
            ErrorItem item;

            item = new ErrorItem("C:\\dir\\file.cs", 1);
            Assert.That(item.FileExtension, Is.EqualTo("cs"));

            item = new ErrorItem("C:\\dir\\file.cpp", 1);
            Assert.That(item.FileExtension, Is.EqualTo("cpp"));

            item = new ErrorItem("C:\\dir\\file.cs.cpp.plop", 1);
            Assert.That(item.FileExtension, Is.EqualTo("plop"));

            item = new ErrorItem("C:\\dir\\file.", 1);
            Assert.That(item.FileExtension, Is.Null);

            item = new ErrorItem("C:\\dir\\file", 1);
            Assert.That(item.FileExtension, Is.Null);

            return;
        }
 /// <summary>
 /// Checks whether the given item belongs to this collection.
 /// </summary>
 /// <param name="item">The item to be checked.</param>
 /// <returns>True if the item belongs to this collection.</returns>
 public bool Contains(ErrorItem item)
 {
     return(_items.Contains(item));
 }
 /// <summary>
 /// Checks whether the given item belongs to this collection.
 /// </summary>
 /// <param name="item">The item to be checked.</param>
 /// <returns>True if the item belongs to this collection.</returns>
 public bool Contains(ErrorItem item) {
     return (_items.Contains(item));
 }