Example #1
0
        public IEnumerable <KeyValuePair <string, string> > GetPairs()
        {
            yield return(new KeyValuePair <string, string>("Sessions", _project.Sessions.Count.ToString()));

            yield return(new KeyValuePair <string, string>("People", _project.People.Count.ToString()));

            yield return(new KeyValuePair <string, string>("", ""));

            //TODO: this will need to be some kind of background operation

            foreach (var definition in SessionComponentDefinition.CreateHardCodedDefinitions().Where(def => def.MeasurementType == SessionComponentDefinition.MeasurementTypes.Time))
            {
                yield return(new KeyValuePair <string, string>(definition.Name,
                                                               GetRecordingDurations(definition).ToString()));
            }

            foreach (var definition in SessionComponentDefinition.CreateHardCodedDefinitions().Where(def => def.MeasurementType == SessionComponentDefinition.MeasurementTypes.Time))
            {
                int    megabytes = GetMegabytes(definition);
                string value;
                if (megabytes > 1000)              //review: is a gigabyte 1000, or 1024 megabytes?
                {
                    value = ((double)megabytes / 1000.0).ToString("N", CultureInfo.InvariantCulture) + " Gigabytes";
                }
                else if (megabytes == 0)
                {
                    value = "---";
                }
                else
                {
                    value = megabytes.ToString("###", CultureInfo.InvariantCulture) + " Megabytes";
                }
                yield return(new KeyValuePair <string, string>(definition.Name, value));
            }
        }
        public void GetOriginalRecordingTime_NoRecording_Zero()
        {
            SessionComponentDefinition originalRecording = SessionComponentDefinition.CreateHardCodedDefinitions().First();

            using (var test = new TestProjectWithSessions(1))
            {
                SpongeProject project = test.Project;
                Assert.AreEqual(new TimeSpan(0),
                                CreateModel(project).GetRecordingDurations(originalRecording));
            }
        }
        public void GetRecordingDurations_SomeRecording_MoreThanZero()
        {
            using (var test = new TestProjectWithSessions(1))
            {
                SessionComponentDefinition firstRole = SessionComponentDefinition.CreateHardCodedDefinitions().First();
                CreateCanonciallyNamedRecordingInSession(firstRole, test.Project.Sessions[0]);

                SpongeProject project = test.Project;
                Assert.Less(new TimeSpan(0),
                            CreateModel(project).GetRecordingDurations(firstRole));
            }
        }
        public void GetRecordingDurations_DistinguishesBetweenRoles()
        {
            using (var test = new TestProjectWithSessions(1))
            {
                SessionComponentDefinition firstRole = SessionComponentDefinition.CreateHardCodedDefinitions().First();
                CreateCanonciallyNamedRecordingInSession(firstRole, test.Project.Sessions[0]);

                SessionComponentDefinition secondRole =
                    SessionComponentDefinition.CreateHardCodedDefinitions().ToArray()[1];

                SpongeProject project = test.Project;
                TimeSpan      t       = CreateModel(project).GetRecordingDurations(secondRole);
                Assert.AreEqual(new TimeSpan(0), t, "should not find any files with the second role");
            }
        }