Exemplo n.º 1
0
 private static bool Bug() {
 ObjectManager objmgr1;
 StreamingContext sc1;
 ObjectIDGenerator objid1;
 TestFixup tstfxp1;
 Int64 iRootID;
 Int64 iChildID;
 String strValue;
 MemberInfo[] members;
 Boolean fFirstTime;
 sc1 = new StreamingContext(StreamingContextStates.All);
 tstfxp1 = new TestFixup();
 strValue = "Hello World";
 objid1 = new ObjectIDGenerator();
 iRootID = objid1.GetId(tstfxp1, out fFirstTime);
 iChildID = objid1.GetId(strValue, out fFirstTime);
 members = FormatterServices.GetSerializableMembers(tstfxp1.GetType()); 
 objmgr1 = new ObjectManager(null, sc1);
 objmgr1.RecordFixup(iRootID, members[0], iChildID);
 try {
 objmgr1.RegisterObject(strValue, iChildID);	
 return true;
 } catch(Exception ex){
 Console.WriteLine("Bug:Exception thrown, " + ex);
 return false;
 }
 }
	// Test simple object identifier generation.
	public void TestObjectIDGeneratorSimple()
			{
				ObjectIDGenerator gen = new ObjectIDGenerator();
				Object obj1 = new Object();
				Object obj2 = new Object();
				Object obj3 = new Object();
				bool firstTime;

				AssertEquals("Simple (1)", 1, gen.GetId(obj1, out firstTime));
				Assert("Simple (2)", firstTime);

				AssertEquals("Simple (3)", 2, gen.GetId(obj2, out firstTime));
				Assert("Simple (4)", firstTime);

				AssertEquals("Simple (5)", 2, gen.GetId(obj2, out firstTime));
				Assert("Simple (6)", !firstTime);

				AssertEquals("Simple (7)", 1, gen.HasId(obj1, out firstTime));
				Assert("Simple (8)", !firstTime);

				AssertEquals("Simple (9)", 0, gen.HasId(obj3, out firstTime));
				Assert("Simple (10)", firstTime);

				AssertEquals("Simple (11)", 3, gen.GetId(obj3, out firstTime));
				Assert("Simple (12)", firstTime);
			}
Exemplo n.º 3
0
        public static void Register(MonoModder self)
        {
            bool firstTime;

            ModderMap[ModderIdGen.GetId(self, out firstTime)] = new WeakReference(self);
            if (!firstTime)
            {
                throw new InvalidOperationException("MonoModder instance already registered in MMILProxyManager");
            }
        }
        public virtual string Serialize(ObjectIDGenerator idGenerator)
        {
            string data = "";

            data += this.GetType().FullName + ",";
            data += idGenerator.GetId(this, out bool firstTime) + ",";
            data += idGenerator.GetId(Item, out firstTime).ToString();

            return(data);
        }
Exemplo n.º 5
0
        internal long RegisterControl(T control)
        {
            long id = IdGenerator.GetId(control, out bool firstTime);

            if (firstTime)
            {
                KnownControls.Add(id, control);
            }

            return(id);
        }
Exemplo n.º 6
0
        public string Serialize(ObjectIDGenerator idGenerator)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(GetType().FullName.ToString() + ",");
            sb.Append(idGenerator.GetId(Katalog, out bool firstTime) + ",");
            sb.Append(RokWydania + ",");
            sb.Append(IdOpisuStanu + ",");
            sb.Append(idGenerator.GetId(this, out firstTime));
            return(sb.ToString());
        }
Exemplo n.º 7
0
        public void TestOne()
        {
            _count++;
            Assert.That(_count, Is.EqualTo(1));

            long id = generator.GetId(this, out bool first);

            Assert.That(first, Is.True);
            Assert.That(id, Is.Not.EqualTo(lastObjectId));
            lastObjectId = id;
        }
    public int Compare(MyType x, MyType y)
    {
        if (x.DateTimeProp != y.DateTimeProp)
        {
            return(x.DateTimeProp.CompareTo(y.DateTimeProp));
        }
        bool firstTime;
        var  xId = idGenerator.GetId(x, out firstTime);
        var  yId = idGenerator.GetId(y, out firstTime);

        return(xId.CompareTo(yId));
    }
Exemplo n.º 9
0
        override public string Serialization(ObjectIDGenerator idGen)
        {
            string data = this.GetType().FullName + ";";

            data += idGen.GetId(this, out bool firstTime) + ";";
            data += idGen.GetId(this.Who, out firstTime) + ";";
            data += idGen.GetId(this.StatusInfo, out firstTime) + ";";
            data += this.Date.ToString("O") + ";";
            data += this.Method_of_payment.ToString() + ";";

            return(data);
        }
Exemplo n.º 10
0
        public virtual string Serialize(ObjectIDGenerator idGenerator)
        {
            string data = "";

            data += this.GetType().FullName + ",";
            data += idGenerator.GetId(this, out bool firstTime) + ",";
            data += idGenerator.GetId(StateDescription, out firstTime) + ",";
            data += idGenerator.GetId(Person, out firstTime) + ",";
            data += this.HireDate.ToShortDateString();

            return(data);
        }
Exemplo n.º 11
0
        public string Serialize(ObjectIDGenerator idGenerator)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(GetType().FullName.ToString() + ",");
            sb.Append(idGenerator.GetId(Wykaz, out bool firstTime) + ",");
            sb.Append(idGenerator.GetId(OpisStanu, out firstTime) + ",");
            sb.Append(DataZdarzenia + ",");
            sb.Append(Guid + ",");
            sb.Append(idGenerator.GetId(this, out firstTime));
            return(sb.ToString());
        }
Exemplo n.º 12
0
    // Check that value-equal objects are given distinct object identifiers.
    public void TestObjectIDGeneratorDistinct()
    {
        ObjectIDGenerator gen  = new ObjectIDGenerator();
        Object            obj1 = (Object)3;
        Object            obj2 = (Object)3;
        long id1;
        long id2;
        bool firstTime;

        id1 = gen.GetId(obj1, out firstTime);
        id2 = gen.GetId(obj2, out firstTime);
        Assert("Distinct (1)", (id1 != id2));
    }
Exemplo n.º 13
0
        public string Serialize(ObjectIDGenerator idGenerator)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(AdresWykazu.Serialize(idGenerator));
            sb.Append(GetType().FullName.ToString() + ",");
            sb.Append(FirstName + ",");
            sb.Append(LastName + ",");
            sb.Append(IdWykazu + ",");
            sb.Append(idGenerator.GetId(this, out bool firstTime) + ",");
            sb.Append(idGenerator.GetId(AdresWykazu, out firstTime));
            return(sb.ToString());
        }
Exemplo n.º 14
0
        public override string Serialize(ObjectIDGenerator idGenerator)
        {
            string data = "";

            data += this.GetType().FullName + ",";
            data += idGenerator.GetId(this, out bool firstTime) + ",";
            data += this.Id + ",";
            data += this.Name + ",";
            data += idGenerator.GetId(Author, out firstTime).ToString() + ",";
            data += this.Pages.ToString() + ",";
            data += this.PublishingHouse;
            return(data);
        }
Exemplo n.º 15
0
        public override string Serialize(ObjectIDGenerator idGenerator)
        {
            string data = "";

            data += this.GetType().FullName + ",";
            data += idGenerator.GetId(this, out bool firstTime) + ",";
            data += idGenerator.GetId(StateDescription, out firstTime) + ",";
            data += idGenerator.GetId(Person, out firstTime) + ",";
            data += this.HireDate.ToString("MM.dd.yyyy") + ",";
            data += this.ReturnDate.GetValueOrDefault().ToString("MM.dd.yyyy");

            return(data);
        }
        public override string Serialize(ObjectIDGenerator idGenerator)
        {
            string data = "";

            data += this.GetType().FullName + ",";
            data += idGenerator.GetId(this, out bool firstTime) + ",";
            data += idGenerator.GetId(Item, out firstTime).ToString() + ",";
            data += this.Description + ",";
            data += this.PurchaseDate.ToShortDateString() + ",";
            data += this.Purpose + ",";
            data += this.Kind;

            return(data);
        }
Exemplo n.º 17
0
        private void Init(object obj)
        {
            bool _;

            Id           = idGen.GetId(obj, out _);
            objCache[Id] = this;
            Type         = obj.GetType();
            var fields = Type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            Fields = Array.AsReadOnly(fields);
            object[] data = new object[fields.Length];
            for (int i = 0; i < fields.Length; i++)
            {
                var    fi  = fields[i];
                object val = fi.GetValue(obj);
                Type   t   = fi.FieldType;
                if (val == null || t.IsPrimitive || (val is MemberInfo && t.IsSerializable))
                {
                    data[i] = val;
                }
                else if (t.IsArray && !t.GetElementType().IsPrimitive)
                {
                    Array orig = (Array)val;
                    ObjectConstructInfo[] arr = new ObjectConstructInfo[orig.Length];
                    for (int j = 0; j < arr.Length; j++)
                    {
                        object aval = orig.GetValue(j);
                        if (aval != null)
                        {
                            arr[j] = new ObjectConstructInfo(aval, objCache);
                        }
                    }
                    data[i] = arr;
                }
                else
                {
                    ObjectConstructInfo oci;
                    if (objCache.TryGetValue(idGen.GetId(val, out _), out oci))
                    {
                        data[i] = oci;
                    }
                    else
                    {
                        data[i] = new ObjectConstructInfo(val, objCache);
                    }
                }
            }
            Data = Array.AsReadOnly(data);
        }
Exemplo n.º 18
0
        private void Schedule(Object toSchedule, object parent)
        {
            if (toSchedule == null)
            {
                return;
            }

            Boolean firstOccurrence;

            m_idGen.GetId(toSchedule, out firstOccurrence);
            if (!firstOccurrence)
            {
                return;
            }

            if (toSchedule.GetType().IsArray || toSchedule.GetType() == typeof(IList))
            {
                foreach (Object item in ((Array)toSchedule))
                {
                    Schedule(item, null);
                }
            }
            else
            {
                m_toWalk.Push(toSchedule);
            }
        }
    private void Consider(object toConsider)
    {
        if (toConsider == null)
        {
            return;
        }
        bool firstOccurrence;

        idGenerator.GetId(toConsider, out firstOccurrence);
        if (!firstOccurrence)
        {
            return;
        }
        if (toConsider.GetType( ).IsArray)
        {
            foreach (var item in (( Array )toConsider))
            {
                Consider(item);
            }
        }
        else
        {
            stack.Push(toConsider);
        }
    }
Exemplo n.º 20
0
        public void Clear(TKey key, Diagnostics.ILog log = null)
        {
            ConcurrentBag <TPooledResource> connections;

            if (!pool.TryRemove(key, out connections))
            {
                return;
            }

            // this looks like it should be connections.Count > 0, however setting it to 0
            // led to an uptick in users seeing Halibut stacktraces in
            // in their logs. This may have just uncovered another issue.
            // We are returning to 1 in Dec 2016 and will monitor. Are
            // we disposing a connection that is in use somehow? Adding the same connection
            // twice?
            var generator = new ObjectIDGenerator();

            while (connections.Count > 1)
            {
                TPooledResource connection;
                if (connections.TryTake(out connection))
                {
                    if (log != null)
                    {
                        bool firstTime;
                        generator.GetId(connection, out firstTime);
                        if (!firstTime)
                        {
                            log.Write(EventType.Error, "Duplicate connection found in conenction pool");
                        }
                    }
                    connection.Dispose();
                }
            }
        }
Exemplo n.º 21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="System.Object" />
 ///     class.
 /// </summary>
 public DefaultObjectIdProvider([NotNull] ObjectIDGenerator generator)
 {
     Generator     = generator ?? throw new ArgumentNullException(nameof(generator));
     _registryById = new ConcurrentDictionary <long, object> ( );
     _registry     = new ConcurrentDictionary <object, long> ( );
     _id           = generator.GetId(this, out _);
 }
Exemplo n.º 22
0
        public List <Client> loadClientFromJson(string path)
        {
            using (StreamReader r = new StreamReader(@path))
            {
                var           json    = r.ReadToEnd();
                List <Client> clients = JsonConvert.DeserializeObject <List <Client> >(json, new JsonSerializerSettings {
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects, TypeNameHandling = TypeNameHandling.Auto
                });
                foreach (Client iterator in clients)
                {
                    idList.Add(generate.GetId(iterator, out ifFirstTime));
                }

                return(clients);
            }
        }
Exemplo n.º 23
0
 public static long GetId(object obj, out bool firstTime)
 {
     lock (ObjectIdGenerator)
     {
         return(ObjectIdGenerator.GetId(obj, out firstTime));
     }
 }
Exemplo n.º 24
0
        public void Serialize(FileStream s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            if (!s.CanWrite)
            {
                throw new ArgumentException("FileStream is not writable!");
            }

            var listNodes   = new ListNode[Count];
            var generator   = new ObjectIDGenerator();
            var currentNode = Head;

            while (currentNode != null)
            {
                var id = generator.GetId(currentNode, out _);
                listNodes[id - 1] = currentNode;
                currentNode       = currentNode.Next;
            }

            using (TextWriter writer = new StreamWriter(s))
            {
                writer.WriteLine(Count);
                currentNode = Head;
                while (currentNode != null)
                {
                    writer.WriteLine(FindIndex(currentNode.Rand, generator));
                    writer.WriteLine(currentNode.Data);
                    currentNode = currentNode.Next;
                }
            }
        }
 public CompanyContext(string connectionString, Company company, ILogger <SapDiApiContext> logger)
 {
     _logger           = logger;
     _objId            = IdGenerator.GetId(this, out _);
     _company          = company;
     _connectionString = connectionString;
 }
    static void Write(ObjectIDGenerator idgen, object obj)
    {
        bool isNew;
        long id = idgen.GetId(obj, out isNew);

        System.Console.WriteLine("{0}, {1}", id, isNew);
    }
Exemplo n.º 27
0
    // Walk the reference of the passed-in object.
    private void Schedule(Object toSchedule)
    {
        if (toSchedule == null)
        {
            return;
        }

        // Ask the ObjectIDManager if this object has been examined before.
        Boolean firstOccurrence;

        m_idGen.GetId(toSchedule, out firstOccurrence);

        // If this object has been examined before, do not look at it again just return.
        if (!firstOccurrence)
        {
            return;
        }

        if (toSchedule.GetType().IsArray)
        {
            // The object is an array, schedule each element of the array to be looked at.
            foreach (Object item in ((Array)toSchedule))
            {
                Schedule(item);
            }
        }
        else
        {
            // The object is not an array, schedule this object to be looked at.
            m_toWalk.Push(toSchedule);
        }
    }
Exemplo n.º 28
0
        public override void Serialize(Stream serializationStream, object graph)
        {
            ISerializable _data = (ISerializable)graph;

            this.serializationStream = serializationStream;
            SerializationInfo _info = new SerializationInfo(graph.GetType(), new FormatterConverter());

            customBinder.BindToName(graph.GetType(), out string assemblyName, out string typeName);
            StreamingContext _context = new StreamingContext(StreamingContextStates.File);

            _data.GetObjectData(_info, _context);

            foreach (SerializationEntry _item in _info)
            {
                this.WriteMember(_item.Name, _item.Value);
            }


            StringBuilder fileContent = new StringBuilder(assemblyName + "|" + typeName + "|" +
                                                          objectIDGenerator.GetId(graph, out bool firstTime)
                                                          .ToString());

            foreach (DataStruct dataStruct in _values)
            {
                fileContent.Append("\n" + dataStruct.ToString());
            }

            fileContent.Append(";\n");
            using (StreamWriter writer = new StreamWriter(serializationStream, Encoding.UTF8, 32, true))
            {
                writer.Write(fileContent.ToString());
            }

            fileContent.Clear();
            _values.Clear();
            _sobjects.Add(graph);
            foreach (Object obj in _objects)
            {
                if (!_sobjects.Contains(obj))
                {
                    this.Serialize(serializationStream, obj);
                }
            }

            serializationStream.Close();
        }
Exemplo n.º 29
0
 public long GetID( ObjectIDGenerator IDGen )
 {
     PlaceHolder p = new PlaceHolder();
     p.holder = 0;
     bool temp;
     lock (p) {
     return IDGen.GetId(p, out temp); }
 }
        private void SerializeCzytelnicy(StreamWriter stream, List <Czytelnik> czytelnicy)
        {
            stream.WriteLine("<" + typeof(List <Czytelnik>).Name + " " + typeof(Czytelnik).Name + ">\n");
            StringBuilder wyp = new StringBuilder();
            string        name;
            object        value;
            Type          type;

            foreach (var i in czytelnicy)
            {
                SerializationInfo info    = new SerializationInfo(typeof(Czytelnik), new FormatterConverter());
                StreamingContext  context = new StreamingContext();
                i.GetObjectData(info, context);
                wyp.Append("(" + typeof(Czytelnik).Name + ")\n");
                wyp.Append("|ID|" + idGenerator.GetId(i, out bool first) + "|/ID|\n");
                foreach (SerializationEntry k in info)
                {
                    name  = k.Name;
                    value = k.Value;
                    wyp.Append("|" + name + "|" + value + "|/" + name + "|\n");
                }
                foreach (SerializationEntry k in info)
                {
                    name = k.Name;
                    type = k.ObjectType;
                    wyp.Append("|" + name + "|" + type.Name + "|/" + name + "|\n");
                }
                wyp.Append("(/" + typeof(Czytelnik).Name + ")\n");
                stream.WriteLine(wyp);
                wyp.Clear();
            }
            stream.WriteLine("</" + typeof(List <Czytelnik>).Name + " " + typeof(Czytelnik).Name + ">");
        }
Exemplo n.º 31
0
        public Sequence(Reactor parent)
        {
            Parent = parent;
            Id     = (ushort)_identity.GetId(this, out var @new);

            if (@new)
            {
                parent.Sequences[Id] = this;
            }
        }
Exemplo n.º 32
0
        private static graphNode createGraphNode(Node n)
        {
            bool      dummyVar;
            long      id = IDgen.GetId(n, out dummyVar);
            graphNode no = new graphNode(id.ToString());

            setNodeAttributes(no.Attr, n.type);
            no.LabelText = n.getLabel();

            return(no);
        }
Exemplo n.º 33
0
        public DIGrainWithInjectedServices(IInjectedService injectedService, IGrainFactory injectedGrainFactory)
        {
            this.injectedService      = injectedService;
            this.injectedGrainFactory = injectedGrainFactory;
            bool set;

            // get the object Id for injected GrainFactory,
            // object Id will be the same if the underlying object is the same,
            // this is one way to prove that this GrainFactory is injected from DI
            this.grainFactoryId = ObjectIdGenerator.GetId(this.injectedGrainFactory, out set);
        }
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		ObjectManager objmgr1 = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		Int64 iRootID;
		Int64 iChildID;
		bool fFirstTime;
		String[] strArr;
		String strToBeFixed;
		TestArrayFixup[] arrTst1;
		TestArrayFixup tst1;
		Int32[] indices;
		String[,] multiArr;
		String anotherString;
		Int64 anotherStringId;
		try {
			do
			{
				strLoc = "Loc_9457and";
				strArr = new String[1];
				strToBeFixed = "Hello World";
				indices = new Int32[1];
				indices[0] = 0;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(strArr, out fFirstTime);
				iChildID = objid1.GetId(strToBeFixed, out fFirstTime);
				objmgr1 = new ObjectManager(null, sc1);
				objmgr1.RecordArrayElementFixup(iRootID, indices, iChildID);
				objmgr1.RegisterObject(strArr, iRootID);
				objmgr1.RegisterObject(strToBeFixed, iChildID);
				iCountTestcases++;
				if(!strArr[0].Equals(strToBeFixed))
				{
					iCountErrors++;
					Console.WriteLine("Err_0452fsd! Expected value not returned, " + strArr[0] + ", expected, " + strToBeFixed);
				}
				objmgr1.DoFixups();
				strLoc = "Loc_017ged";
				iCountTestcases++;
				if(!strArr[0].Equals(strToBeFixed))
				{
					iCountErrors++;
					Console.WriteLine("Err_90453vdf! Expected value not returned, " + strArr[0] + ", expected, " + strToBeFixed);
				}
				multiArr = new String[5, 10];
				indices = new Int32[2];
				indices[0] = 1;
				indices[1] = 5;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(multiArr, out fFirstTime);
				strToBeFixed = "Hello World";
				iChildID = objid1.GetId(strToBeFixed, out fFirstTime);
				objmgr1 = new ObjectManager(null, sc1);
				objmgr1.RecordArrayElementFixup(iRootID, indices, iChildID);
				objmgr1.RegisterObject(multiArr, iRootID);
				objmgr1.RegisterObject(strToBeFixed, iChildID);
				iCountTestcases++;
				if(!multiArr[1, 5].Equals(strToBeFixed)){
					iCountErrors++;
					Console.WriteLine("Err_79435sdg_! Expected value not returned, " + multiArr[1,5] + ", expected, " + strToBeFixed);
				}
				strLoc = "Loc_1294cd";
				arrTst1 = new TestArrayFixup[10];
				tst1 = new TestArrayFixup();
				indices = new Int32[1];
				indices[0] = 5;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(arrTst1, out fFirstTime);
				iChildID = objid1.GetId(tst1, out fFirstTime);
				objmgr1 = new ObjectManager(null, sc1);
				objmgr1.RecordArrayElementFixup(iRootID, indices, iChildID);
				objmgr1.RegisterObject(arrTst1, iRootID);
				objmgr1.RegisterObject(tst1, iChildID);
				iCountTestcases++;
				if(arrTst1[5].iValue != tst1.iValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_112sx! Expected value not returned, " + arrTst1[5].iValue + ", expected, " + tst1.iValue);
				}
				objmgr1.DoFixups();
				strLoc = "Loc_017ged";
				iCountTestcases++;
				if(arrTst1[5].iValue != tst1.iValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_2048cd! Expected value not returned, " + arrTst1[5].iValue + ", expected, " + tst1.iValue);
				}
				strLoc = "Loc_83476tsg";
				iCountTestcases++;
				strArr = new String[1];
				strToBeFixed = "Hello World";
				indices = new Int32[2];
				indices[0] = 0;
				indices[1] = 0;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(strArr, out fFirstTime);
				iChildID = objid1.GetId(strToBeFixed, out fFirstTime);
				objmgr1 = new ObjectManager(null, sc1);
				objmgr1.RecordArrayElementFixup(iRootID, indices, iChildID);
				objmgr1.RegisterObject(strArr, iRootID);
				try{
					objmgr1.RegisterObject(strToBeFixed, iChildID);
					iCountErrors++;
					Console.WriteLine("Err_0452fsd! Exception not thrown");
				}catch(ArgumentException){
				}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_0452fsd! Wrong Exception thrown, " + ex.GetType().Name);
				}
				strLoc = "Loc_9457and";
				iCountTestcases++;
				strArr = new String[5];
				strToBeFixed = "Hello World";
				indices = new Int32[1];
				indices[0] = 0;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(strArr, out fFirstTime);
				iChildID = objid1.GetId(strToBeFixed, out fFirstTime);
				anotherString = "Another String";
				anotherStringId = objid1.GetId(anotherString, out fFirstTime);
				objmgr1 = new ObjectManager(null, sc1);
				objmgr1.RecordArrayElementFixup(iRootID, indices, iChildID);
				objmgr1.RegisterObject(strArr, iRootID);
				objmgr1.RegisterObject(anotherString, anotherStringId);
				try{
					objmgr1.DoFixups();
					iCountErrors++;
					Console.WriteLine("Err_0452fsd! Exception not thrown");
				}catch(SerializationException){
				}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_0452fsd! Wrong Exception thrown, " + ex.GetType().Name);
				}
				try {
					iCountTestcases++;
					objmgr1.RecordArrayElementFixup(-1, indices, iChildID);
					iCountErrors++;
					Console.WriteLine("Err_034cd! exception not thrown");
					}catch(ArgumentOutOfRangeException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_034cd! Unexpected exception, " + ex.ToString());
				}
				try {
					iCountTestcases++;
					objmgr1.RecordArrayElementFixup(2, indices, -5);
					iCountErrors++;
					Console.WriteLine("Err_943cdd! exception not thrown");
					}catch(ArgumentOutOfRangeException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_0834csd! Unexpected exception, " + ex.ToString());
				}
				try {
					iCountTestcases++;
					indices = new Int32[1];
					indices[0] = -5;
					objmgr1.RecordArrayElementFixup(100, indices, 50);
					Console.WriteLine("Loc_943cdd! exception not thrown");
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_8321sd! Unexpected exception, " + ex.ToString());
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
Exemplo n.º 35
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		int iCountErrors = 0;
		int iCountTestcases = 0;
		ObjectManager objmgr1 = null;
		ISurrogateSelector isur = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		bool fFirstTime;
		MemberInfo[] members = null;
		try
		{
			strLoc = "Loc_9347sg";
			iCountTestcases++;
			try{
				ConstructOM(); 
				iCountErrors++;
				Console.WriteLine("Err_7349sg! No exception thrown, ");
			}catch(SecurityException){
			}catch(Exception ex){
				iCountErrors++;
				Console.WriteLine("Err_348tdg! Wrong exception thrown, " + ex.GetType().Name);
			}
			strLoc = "Loc_3946tsg";
			iCountTestcases++;
			tstfxp1 = new TestFixup();
			objid1 = new ObjectIDGenerator();
			iRootID = objid1.GetId(tstfxp1, out fFirstTime);
			strValue = "Hello World";
			iChildID = objid1.GetId(strValue, out fFirstTime);
			members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
			objmgr1 = new ObjectManager(isur, sc1);
			objmgr1.RecordFixup(iRootID, members[0], iChildID);
			objmgr1.RegisterObject(tstfxp1, iRootID);
			objmgr1.RegisterObject(strValue, iChildID);
			iCountTestcases++;
			if(!tstfxp1.strFixupValue.Equals(strValue))
			{
				iCountErrors++;
				Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
			}
			objmgr1.DoFixups();
			iCountTestcases++;
			if(!tstfxp1.strFixupValue.Equals(strValue))
			{
				iCountErrors++;
				Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
			}
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,inCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
	// Test exception cases.
	public void TestObjectIDGeneratorExceptions()
			{
				ObjectIDGenerator gen = new ObjectIDGenerator();
				bool firstTime;
				try
				{
					gen.GetId(null, out firstTime);
					Fail("Exceptions (1)");
				}
				catch(ArgumentNullException)
				{
					// Success.
				}
				try
				{
					gen.HasId(null, out firstTime);
					Fail("Exceptions (1)");
				}
				catch(ArgumentNullException)
				{
					// Success.
				}
			}
Exemplo n.º 37
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		IFormatter formatter;
		SurrogateSelector selector;
		MySerializationSurrogate surrogate;
		StreamingContext context = new StreamingContext(StreamingContextStates.All);
		MemoryStream stream;
		Int32 iValue;
		A a;
		ObjectManager manager;
		ObjectIDGenerator generator;
		Int64 rootId;
		Int64 childId;
		Boolean firstTime;
		MemberInfo[] members;
		try {
			strLoc = "Loc_29457sdg";
			iCountTestcases++;
			selector = new SurrogateSelector();
			surrogate = new MySerializationSurrogate();
			selector.AddSurrogate(typeof(A), context, surrogate);
			formatter = new BinaryFormatter();
			formatter.SurrogateSelector = selector;
			stream = new MemoryStream();
			a = new A();
			a.I = 10;
			formatter.Serialize(stream, a);
			stream.Position = 0;
			A a1 = (A)formatter.Deserialize(stream);
			if(a1.I != 30){
				iCountErrors++;
				Console.WriteLine("Err_753ffd! Unexpected value returned, Value: <{0}>", a1.I);
			}
			strLoc = "Loc_8394tfsg";
			iCountTestcases++;
			generator = new ObjectIDGenerator();
			a = new A();
			iValue = 500;
			rootId = generator.GetId(a, out firstTime);
			childId = generator.GetId(iValue, out firstTime);
			selector = new SurrogateSelector();
			surrogate = new MySerializationSurrogate();
			selector.AddSurrogate(typeof(A), context, surrogate);
			manager = new ObjectManager(selector, context);
			members = FormatterServices.GetSerializableMembers(typeof(A));
			manager.RecordDelayedFixup(rootId, "Int32Twist", childId);
			try{
				SerializationInfo serInfo1 = new SerializationInfo(typeof(A), new FormatterConverter());
				manager.RegisterObject(a, rootId, serInfo1);
				manager.RegisterObject(iValue, childId);
				Console.WriteLine(a.I);
			}catch(Exception ex){
				iCountErrors++;
				Console.WriteLine(ex);
			}
			strLoc = "Loc_87sgsfd";
			iCountTestcases++;
			generator = new ObjectIDGenerator();
			a = new A();
			iValue = 500;
			rootId = generator.GetId(a, out firstTime);
			childId = generator.GetId(iValue, out firstTime);
			manager = new ObjectManager(null, context);
			members = FormatterServices.GetSerializableMembers(typeof(A));
			manager.RecordFixup(rootId, members[0], childId);
			manager.RegisterObject(a, rootId);
			manager.RegisterObject(iValue, childId);
			if(a.I != 500){
				iCountErrors++;
				Console.WriteLine("Err_93745sg! Unexpected value returned, Value: <{0}>", a1.I);
			}
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		ObjectManager objmgr1 = null;
		ISurrogateSelector isur = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		String strValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		TestReference tst1;
		ThisImplementsIObjectReference tst2;
		try {
			do
			{
				strLoc="Loc_174cds";
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello World";
				iChildID = objid1.GetId(strValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				objmgr1.RegisterObject(tstfxp1, iRootID);
				objmgr1.RegisterObject(strValue, iChildID);
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				objmgr1.DoFixups();
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				strLoc="Loc_5720xs";
				tst1 = new TestReference();
				tst2 = new ThisImplementsIObjectReference();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				iChildID = objid1.GetId(tst2, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(TestReference));
				Console.WriteLine("<<" + members[0].Name + ">>");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				objmgr1.RegisterObject(tst1, iRootID);
				objmgr1.RegisterObject(tst2, iChildID);
				try{
					iCountTestcases++;
					objmgr1.DoFixups();
					iCountErrors++;
					Console.WriteLine("Err_753fvdf! exception not thrown!!");
				}catch(SerializationException){
				}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_04523cd! Unexpected exception, " + ex.ToString());
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
	// Add large numbers of objects to an ObjectIDGenerator.
	public void TestObjectIDGeneratorMany()
			{
				ObjectIDGenerator gen = new ObjectIDGenerator();
				Object[] list = new Object [1024];
				bool firstTime;
				int posn;
				for(posn = 0; posn < 1024; ++posn)
				{
					list[posn] = new Object();
					AssertEquals("Many (1)", posn + 1,
								 gen.GetId(list[posn], out firstTime));
					Assert("Many (2)", firstTime);
					AssertEquals("Many (3)", (posn / 2) + 1,
								 gen.GetId(list[posn / 2], out firstTime));
					Assert("Many (4)", !firstTime);
					AssertEquals("Many (5)", (posn / 2) + 1,
								 gen.HasId(list[posn / 2], out firstTime));
					Assert("Many (6)", !firstTime);
				}
			}
	// Check that value-equal objects are given distinct object identifiers.
	public void TestObjectIDGeneratorDistinct()
			{
				ObjectIDGenerator gen = new ObjectIDGenerator();
				Object obj1 = (Object)3;
				Object obj2 = (Object)3;
				long id1;
				long id2;
				bool firstTime;
				id1 = gen.GetId(obj1, out firstTime);
				id2 = gen.GetId(obj2, out firstTime);
				Assert("Distinct (1)", (id1 != id2));
			}
Exemplo n.º 41
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		ObjectManager objmgr1 = null;
		ISurrogateSelector isur = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		String strValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		Test1 tst1;
		A a1;
		Int32 iOurMan;
		Boolean fChildFound;
		Test2 tst2;
		Test3 tst3;
		B b1;
		try {
			do
			{
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello World";
				iChildID = objid1.GetId(strValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				objmgr1.RegisterObject(tstfxp1, iRootID);
				objmgr1.RegisterObject(strValue, iChildID);
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				objmgr1.DoFixups();
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				tst1 = new Test1();
				a1 = new A();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				iChildID = objid1.GetId(a1, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test1));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("a")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_342ds! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[iOurMan], iChildID);
				try{
					iCountTestcases++;
					objmgr1.RegisterObject(a1, iChildID);
					objmgr1.RegisterObject(tst1, iRootID);
					objmgr1.DoFixups();
					Console.WriteLine("Loc_0283! exception not thrown");
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_04523cd! Unexpected exception, " + ex.ToString());
				}
				tst1 = new Test1();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				a1 = new A();
				iChildID = objid1.GetId(a1, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test1));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("a")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_342ds! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[iOurMan], iChildID);
				try{
					iCountTestcases++;
					objmgr1.DoFixups();
					iCountErrors++;
					Console.WriteLine("Err_7453fd! exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_1204cd! Unexpected exception, " + ex.ToString());
				}
				tst1 = new Test1();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				a1 = new A();
				iChildID = objid1.GetId(a1, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test1));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("a")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_342ds! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				try{
					iCountTestcases++;
					objmgr1.RegisterObject(a1, iChildID);
					objmgr1.RegisterObject(tst1, iRootID);
					objmgr1.RecordFixup(iRootID, members[iOurMan], iChildID);
					objmgr1.DoFixups();
					Console.WriteLine("Loc_02843cd! exception not thrown");
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_0438fd! Unexpected exception, " + ex.ToString());
				}
				tst1 = new Test1();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				a1 = new A();
				iChildID = objid1.GetId(a1, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test1));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("a")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_342fsd! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				try{
					iCountTestcases++;
					objmgr1.RegisterObject(a1, iChildID);
					objmgr1.RegisterObject(tst1, iRootID);
					objmgr1.DoFixups();
					Console.WriteLine("Loc_94523fsd! exception not thrown");
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_0348dcs! Unexpected exception, " + ex.ToString());
				}
				tst2 = new Test2();
				tst3 = new Test3();
				b1 = new B();
				b1.StrValue = "Hello World";
				tst3.Set_B=b1;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst2, out fFirstTime);
				iChildID = objid1.GetId(tst3, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test2));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("tst3")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_024fd! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[iOurMan], iChildID);
				objmgr1.RegisterObject(tst2, iRootID);
				objmgr1.RegisterObject(tst3, iChildID);
				iCountTestcases++;
				Console.WriteLine("Loc_4523vfd! we hve, " + tst2.StrValue);
				if(!tst2.StrValue.Equals("Hello World"))
				{
					iCountErrors++;
					Console.WriteLine("Err_038qm! Expected value not returned, " + tst2.StrValue);
				}
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello World";
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(null, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iRootID);
				try{
					iCountTestcases++;
					objmgr1.RegisterObject(tstfxp1, iRootID);
					iCountErrors++;
					Console.WriteLine("Err_753cd! exception not thrown");
					}catch(ArgumentException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_04523cd! Unexpected exception, " + ex.ToString());
				}
				try
				{
					iCountTestcases++;
					objmgr1.RecordFixup(-1, members[0], iChildID);
					iCountErrors++;
					Console.WriteLine("Err_034cd! exception not thrown");
				}
				catch(ArgumentOutOfRangeException){}
				catch(Exception ex)
				{
					iCountErrors++;
					Console.WriteLine("Err_034cd! Unexpected exception, " + ex.ToString());
				}
				try
				{
					iCountTestcases++;
					objmgr1.RecordFixup(iRootID, members[0], -5);
					iCountErrors++;
					Console.WriteLine("Err_037csd! exception not thrown");
				}
				catch(ArgumentOutOfRangeException){}
				catch(Exception ex)
				{
					iCountErrors++;
					Console.WriteLine("Err_710ca! Unexpected exception, " + ex.ToString());
				}
				try
				{
					iCountTestcases++;
					objmgr1.RecordFixup(iRootID, null, iChildID);
					iCountErrors++;
					Console.WriteLine("Err_048cs! exception not thrown");
				}
				catch(ArgumentNullException){}
				catch(Exception ex)
				{
					iCountErrors++;
					Console.WriteLine("Err_079cd! Unexpected exception, " + ex.ToString());
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
Exemplo n.º 42
0
 public virtual bool runTest()
 {
    Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
    int iCountErrors = 0;
    int iCountTestcases = 0;
    String strLoc = "Loc_000oo";
    try {
    do
    {
      ObjectIDGenerator objIDGen;
      Object obj;
      long objId1, objId2;
      bool firstTime;
      Object boo2, cur2, dt2, dec2, dbl2, gui2, i16, i32, i64, sgl2, ts2;
      strLoc = "Loc_100aa";
      objIDGen = new ObjectIDGenerator();
      obj = null;
      iCountTestcases++;
      try
      {
        objIDGen.HasId(null, out firstTime);
        iCountErrors++;
        printerr("Error_289t2! Expected Exception not thrown");
      } catch (ArgumentException aExc) {}
      catch (Exception exc)
      {
        iCountErrors++;
        printerr("Error_t2gsa! Incorrect Exception thrown : exc=="+exc.ToString());
      }
      strLoc = "Loc_150aa";
      objIDGen = new ObjectIDGenerator();
      obj = new Decimal(10);
      iCountTestcases++;
      objId1 = objIDGen.HasId(obj, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_209ts");
      }
      objId1 = objIDGen.HasId(obj, out firstTime);
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_209ts");
      }
      if(objId1 != 0)
      {
        iCountErrors++;
        printerr("Error_150bb! Did not return null for non-existent object");
      }
      strLoc = "Loc_200aa";
      objIDGen = new ObjectIDGenerator();
      obj = new Decimal(10);
      objId1 = objIDGen.GetId(obj, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_200bb! Whoa, This object haven't been searched for before.");
      }
      strLoc = "Loc_300aa";
      objIDGen = new ObjectIDGenerator();
      obj = new Decimal(10);
      objId1 = objIDGen.GetId(obj, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_300bb! Whoa, This object haven't been searched for before.");
      }
      objId2 = objIDGen.HasId(obj, out firstTime);
      iCountTestcases++;
      if(objId1 != objId2)
      {
        iCountErrors++;
        printerr("Error_300cc! Different object id's returned for the same object");
      }
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_300ee! This object has already been queried, firsttime should be false");
      }
      strLoc = "Loc_400aa";
      boo2 = false;
      dt2 = DateTime.Now;
      dec2 = new Decimal(15.2);
      dbl2 = ((Double)12.2);
      gui2 = Guid.NewGuid();
      i16 = ((Int16)18);
      i32 = ((Int32)42);
      i64 = ((Int64)11);
      sgl2 = ((Single)(Single)3.4);
      ts2 = new TimeSpan(12, 12, 12);
      objIDGen = new ObjectIDGenerator();
      strLoc = "Loc_32948";
      objId1 = objIDGen.GetId(boo2, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_400bb! FirstTime is incorrectly false");
      }
      objId2 = objIDGen.HasId(boo2, out firstTime);
      iCountTestcases++;
      if(objId1 != objId2)
      {
        iCountErrors++;
        printerr("Error_400cc! Object id's not same for same object");
      }
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_400dd! FirstTime is incorrectly false");
      }
      strLoc = "Loc_600aa";
      objId1 = objIDGen.GetId(dt2, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_600bb! FirstTime is incorrectly false");
      }
      objId2 = objIDGen.HasId(dt2, out firstTime);
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_600cc! FirstTime is incorrectl true");
      }
      iCountTestcases++;
      if(objId2 != objId1)
      {
        iCountErrors++;
        printerr("Error_600dd! Object Id's different for same object");
      }
      strLoc = "Loc_700aa";
      objId1 = objIDGen.GetId(dec2, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_700bb! FirstTime is incorrectly false");
      }
      objId2 = objIDGen.HasId(dec2, out firstTime);
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_700cc! FirstTime is incorrecly true");
      }
      iCountTestcases++;
      if(objId2 != objId1)
      {
        iCountErrors++;
        printerr("Error_700dd! Object id's different for same object");
      }
      strLoc = "Loc_800aa";
      objId1 = objIDGen.GetId(dbl2, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_800bb! FirstTime is incorrectly false");
      }
      objId2 = objIDGen.HasId(dbl2, out firstTime);
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_800cc! FirstTime is incorrecly true");
      }
      iCountTestcases++;
      if(objId2 != objId1)
      {
        iCountErrors++;
        printerr("Error_800dd! Object id's different for same object");
      }
      strLoc = "Loc_900aa";
      objId1 = objIDGen.GetId(gui2, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_800bb! FirstTime is incorrectly false");
      }
      objId2 = objIDGen.HasId(gui2, out firstTime);
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_800cc! FirstTime is incorrecly true");
      }
      iCountTestcases++;
      if(objId2 != objId1)
      {
        iCountErrors++;
        printerr("Error_800dd! Object id's different for same object");
      }
      strLoc = "Loc_1000a";
      objId1 = objIDGen.GetId(i16, out firstTime);
      iCountTestcases++;
      if(!firstTime)
      {
        iCountErrors++;
        printerr("Error_1000b! FirstTime is incorrectly false");
      }
      objId2 = objIDGen.HasId(i16, out firstTime);
      iCountTestcases++;
      if(firstTime)
      {
        iCountErrors++;
        printerr("Error_1000c! FirstTime is incorrecly true");
      }
      iCountTestcases++;
      if(objId2 != objId1)
      {
        iCountErrors++;
        printerr("Error_1000d! Object id's different for same object");
      }
      strLoc = "Loc_2805fe";
      objIDGen = new ObjectIDGenerator();
      dec2 = new Decimal(10);
      dbl2 = ((Double)10);
      objId1 = objIDGen.GetId(dec2, out firstTime);
      objId2 = objIDGen.HasId(dbl2, out firstTime);
      iCountTestcases++;
      if(objId1 == objId2)
      {
        iCountErrors++;
        printerr("Error_98532! Id's of two different objects are equal");
      }
    } while (false);
    } catch (Exception exc_general ) {
       ++iCountErrors;
       Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
    }
    if ( iCountErrors == 0 )
    {
       Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
       return true;
    }
    else
    {
       Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
       return false;
    }
 }
Exemplo n.º 43
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		ObjectManager objmgr1 = null;
		ISurrogateSelector isur = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		Int32 iValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		SerializationInfo serInfo1;
		try {
			do
			{
				strLoc = "Loc_8345vdfv";
				tstfxp1 = new TestFixup();
				iValue = 10;
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				iChildID = objid1.GetId(iValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordDelayedFixup(iRootID, "iFixupValue", iChildID);
				serInfo1 = new SerializationInfo(typeof(TestFixup), new FormatterConverter());
				objmgr1.RegisterObject(tstfxp1, iRootID, serInfo1);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)==null)
				{
					iCountErrors++;
					Console.WriteLine("Err_0943fd! Null returned");
				}
				objmgr1.RegisterObject(iValue, iChildID);
				objmgr1.DoFixups();
				strLoc = "Loc_017ged";
				iCountTestcases++;
				if(tstfxp1.iFixupValue != iValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.iFixupValue.ToString() + ", expected, " + iValue.ToString());
				}
				strLoc = "Loc_0358vdf";
				try
				{
					iCountTestcases++;
					objmgr1.RegisterObject(null, iRootID, serInfo1);
					iCountErrors++;
					Console.WriteLine("Err_034cd! exception not thrown");
				}
				catch(ArgumentNullException){}
				catch(Exception ex)
				{
					iCountErrors++;
					Console.WriteLine("Err_03472fd! Unexpected exception, " + ex.ToString());
				}
				try
				{
					iCountTestcases++;
					objmgr1.RegisterObject(tstfxp1, -5, serInfo1);
					iCountErrors++;
					Console.WriteLine("Err_037csd! exception not thrown");
				}
				catch(ArgumentOutOfRangeException){}
				catch(Exception ex)
				{
					iCountErrors++;
					Console.WriteLine("Err_710ca! Unexpected exception, " + ex.ToString());
				}
				try
				{
					iCountTestcases++;
					objmgr1.RegisterObject(tstfxp1, 5, null);
					Console.WriteLine("Loc_048cs! exception not thrown");
				}
				catch(Exception ex)
				{
					iCountErrors++;
					Console.WriteLine("Err_079cd! Unexpected exception, " + ex.ToString());
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
Exemplo n.º 44
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		ObjectManager objmgr1 = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		String strValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		try {
			do
			{
				strLoc="Loc_174cds";
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello Universe";
				iChildID = objid1.GetId(strValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(null, sc1);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)!=null)
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + objmgr1.GetObject(iRootID));
				}
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)!=null)
				{
					iCountErrors++;
					Console.WriteLine("Err_048fd! Expected value not returned, " + objmgr1.GetObject(iRootID));
				}
				objmgr1.RegisterObject(tstfxp1, iRootID);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)==null)
				{
					iCountErrors++;
					Console.WriteLine("Err_0943fd! Null returned");
				}
				iCountTestcases++;
				if(!((TestFixup)(objmgr1.GetObject(iRootID))).strFixupValue.Equals("Hello World"))
				{
					iCountErrors++;
					Console.WriteLine("Err_047fe! wrong value returned returned, " + ((TestFixup)(objmgr1.GetObject(iRootID))).strFixupValue);
				}
				objmgr1.RegisterObject(strValue, iChildID);
				iCountTestcases++;
				if(objmgr1.GetObject(iChildID)==null)
				{
					iCountErrors++;
					Console.WriteLine("Err_90853vdf! Null returned");
				}
				iCountTestcases++;
				if(!objmgr1.GetObject(iChildID).Equals("Hello Universe"))
				{
					iCountErrors++;
					Console.WriteLine("Err_1084cs! wrong value returned returned, " + objmgr1.GetObject(iChildID));
				}
				try{
					iCountTestcases++;
					objmgr1.GetObject(-5);
					iCountErrors++;
					Console.WriteLine("Err_04872d! Exception not thrown");
					}catch(ArgumentOutOfRangeException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_1083xs! Wrong Exception thrown, " + ex);
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}