Example #1
0
        bool CompareJobSources(Dictionary <RecordingJobSource, RecordingJobSource> common,
                               StringBuilder logger)
        {
            bool ok = true;

            foreach (RecordingJobSource info1 in common.Keys)
            {
                string             token = info1.SourceToken.Token;
                string             type  = info1.SourceToken.Type;
                RecordingJobSource info2 = common[info1];

                StringBuilder dump =
                    new StringBuilder(string.Format("      Information for RecordingJobSource with token '{0}' (type '{1}') is different:{2}",
                                                    token, type, Environment.NewLine));

                bool localOk = CompareJobSourceInformation(info1, info2, dump);

                if (!localOk)
                {
                    logger.Append(dump.ToString());
                    ok = false;
                }
            }

            return(ok);
        }
Example #2
0
        public void RecordingJobConfigurationDiffPriorTest2()
        {
            string recordingToken = string.Empty;
            string profileToken   = string.Empty;
            string jobToken       = string.Empty;
            string jobTokenSecond = string.Empty;

            bool recordingCreated            = false;
            bool isRecordingJobDeleted       = false;
            bool isRecordingJobSecondDeleted = false;

            RunTest(() =>
            {
                // A.15 - Selection or Creation of Recording for recording job creation on a Media profile
                GetRecordingForJobCreationMediaProfile(out recordingToken, out profileToken, out recordingCreated, 1);

                // pass test if there is no recording token and profile token
                if (recordingToken == string.Empty && profileToken == string.Empty)
                {
                    return;
                }

                // create 1st recording job configuration
                var source = new RecordingJobSource
                {
                    SourceToken = new SourceReference {
                        Token = profileToken, Type = PROFILESOURCETYPE
                    },
                    AutoCreateReceiverSpecified = false
                };

                var jobConfiguration = new RecordingJobConfiguration
                {
                    RecordingToken = recordingToken,
                    Mode           = ACTIVE,
                    Priority       = 1,
                    Source         = new[] { source }
                };
                var confStand = (RecordingJobConfiguration)CopyObject(jobConfiguration);

                // create 1st recording job
                jobToken = CreateRecordingJob(ref jobConfiguration);

                Assert(!string.IsNullOrEmpty(jobToken),
                       "Job token wasn't returned",
                       "Check that job token was returned");

                ValidateRecordingJobConfiguration(jobConfiguration, confStand);

                // wait
                Sleep(_operationDelay);

                // get job state
                RecordingJobStateInformation info = GetRecordingJobState(jobToken);

                ValidateJobState(info, recordingToken, ACTIVE);

                // create 1st recording job configuration
                var jobConfigurationSecond      = confStand;
                jobConfigurationSecond.Priority = 2;
                confStand = (RecordingJobConfiguration)CopyObject(jobConfigurationSecond);

                // create 2nd recording job
                jobTokenSecond = CreateRecordingJob(ref jobConfigurationSecond);

                Assert(!string.IsNullOrEmpty(jobTokenSecond),
                       "Job token wasn't returned",
                       "Check that job token was returned");

                ValidateRecordingJobConfiguration(jobConfigurationSecond, confStand);

                // wait
                Sleep(_operationDelay);

                // get job state
                info = GetRecordingJobState(jobToken);
                ValidateJobState(info, recordingToken, IDLE);

                // get job state
                info = GetRecordingJobState(jobTokenSecond);
                ValidateJobState(info, recordingToken, ACTIVE);

                // delete 2nd job
                DeleteRecordingJob(jobTokenSecond);
                isRecordingJobSecondDeleted = true;

                // wait
                Sleep(_operationDelay);

                // get job state
                info = GetRecordingJobState(jobToken);
                ValidateJobState(info, recordingToken, ACTIVE);

                // delete 1st job
                DeleteRecordingJob(jobToken);
                isRecordingJobDeleted = true;
            }, () =>
            {
                if (!isRecordingJobDeleted && !string.IsNullOrEmpty(jobToken))
                {
                    DeleteRecordingJob(jobToken);
                }

                if (!isRecordingJobSecondDeleted && !string.IsNullOrEmpty(jobTokenSecond))
                {
                    DeleteRecordingJob(jobTokenSecond);
                }

                if (recordingCreated && !string.IsNullOrEmpty(recordingToken))
                {
                    DeleteRecording(recordingToken);
                }
            });
        }
Example #3
0
        bool CompareJobSourceInformation(RecordingJobSource source1,
                                         RecordingJobSource source2,
                                         StringBuilder logger)
        {
            bool          ok   = true;
            StringBuilder dump = new StringBuilder();

            // AutoCreateReceiver is not specified, if information is valid.

            // Extension - SKIP ?

            // Token - as ID ?


            // Tracks...

            bool list1empty = source1.Tracks == null || source1.Tracks.Length == 0;
            bool list2empty = source2.Tracks == null || source2.Tracks.Length == 0;

            if (!list1empty && !list2empty)
            {
                List <string> notUnique1 = new List <string>();
                List <string> notUnique2 = new List <string>();

                foreach (RecordingJobTrack track in source1.Tracks)
                {
                    int cnt1 = source1.Tracks.Count(t => t.SourceTag == track.SourceTag);
                    if (cnt1 > 1)
                    {
                        notUnique1.Add(track.SourceTag);
                    }
                }
                foreach (RecordingJobTrack track in source2.Tracks)
                {
                    int cnt2 = source2.Tracks.Count(t => t.SourceTag == track.SourceTag);
                    if (cnt2 > 1)
                    {
                        notUnique2.Add(track.SourceTag);
                    }
                }

                if (notUnique1.Count > 0)
                {
                    dump.AppendFormat("         Tracks list is invalid when information is received from GetRecordingJobs. The following SourceTags are not unique: {0}{1}",
                                      string.Join(",", notUnique1.ToArray()), Environment.NewLine);

                    ok = false;
                }
                if (notUnique2.Count > 0)
                {
                    dump.AppendFormat("         Tracks list is invalid when information is received from GetRecordingJobConfiguration. The following SourceTags are not unique: {0}{1}",
                                      string.Join(",", notUnique2.ToArray()), Environment.NewLine);

                    ok = false;
                }

                if (notUnique1.Count == 0 && notUnique2.Count == 0)
                {
                    List <string> commonTags = new List <string>();

                    foreach (RecordingJobTrack track in source1.Tracks)
                    {
                        RecordingJobTrack second =
                            source2.Tracks.Where(t => t.SourceTag == track.SourceTag && t.Destination == track.Destination).
                            FirstOrDefault();
                        if (second == null)
                        {
                            dump.AppendFormat(
                                string.Format(
                                    "         Track with SourceTag = '{0}', Destination = '{1}' not found in tracks list in structure received from GetRecordingJobConfiguration{2}",
                                    track.SourceTag, track.Destination, Environment.NewLine));
                            ok = false;
                        }
                    }
                    foreach (RecordingJobTrack track in source2.Tracks)
                    {
                        int cnt = source1.Tracks.Count(t => t.SourceTag == track.SourceTag && t.Destination == track.Destination);
                        if (cnt == 0)
                        {
                            dump.AppendFormat(
                                string.Format(
                                    "         Track with SourceTag = '{0}', Destination = '{1}' not found in tracks list in structure received from GetRecordingJobs{2}",
                                    track.SourceTag, track.Destination, Environment.NewLine));
                            ok = false;
                        }
                    }
                }
            }
            else
            {
                if (!(list1empty && list2empty))
                {
                    dump.AppendLine("         Tracks list is present only in one structure");
                    ok = false;
                }
            }


            if (!ok)
            {
                logger.Append(dump.ToString());
            }

            return(ok);
        }