示例#1
0
		public void SessionDate_DateRange_ValidStringProduced()
		{
			var session = new Session();
			const string dateIn = "2013-11-20 to 2013-11-25";

			session.SetDate(dateIn);

			var dateOut = session.Date;

			Assert.AreEqual(dateIn, dateOut, "The date returned was not what was expected.");
		}
示例#2
0
		public void SessionDate_DateTime_ValidStringProduced()
		{
			var session = new Session();
			var dateIn = DateTime.Today;

			session.SetDate(dateIn);

			var dateOut = session.Date;

			Assert.AreEqual(dateIn.ToString("yyyy-MM-dd"), dateOut, "The date returned was not what was expected.");
		}
示例#3
0
		public void SessionDate_YearOnly_ValidStringProduced()
		{
			var session = new Session();
			const int dateIn = 1964;

			session.SetDate(dateIn);

			var dateOut = session.Date;

			Assert.AreEqual(dateIn.ToString(CultureInfo.InvariantCulture), dateOut, "The date returned was not what was expected.");
		}
示例#4
0
		public void SessionAddActor_Anonymized_RemovesActorFiles()
		{
			ArchivingActor actor = new ArchivingActor
			{
				Name = "Actor Name",
				FullName = "Actor Full Name",
				Anonymize = true
			};

			actor.Files.Add(new ArchivingFile(System.Reflection.Assembly.GetExecutingAssembly().Location));

			Session session = new Session();
			session.AddActor(actor);

			Assert.AreEqual(0, session.Resources.MediaFile.Count);
			Assert.AreEqual(0, session.Resources.WrittenResource.Count);
		}
示例#5
0
		public void SessionAddActor_Anonymized_ReturnsAnonymizedNames()
		{
			ArchivingActor actor = new ArchivingActor
			{
				Name = "Actor Name",
				FullName = "Actor Full Name",
				Anonymize = true
			};

			Session session = new Session();
			session.AddActor(actor);

			var imdiActor = session.MDGroup.Actors.Actor[0];

			Assert.AreNotEqual("Actor Name", imdiActor.Name[0]);
			Assert.AreNotEqual("Actor Full Name", imdiActor.FullName);
		}
		/// <summary>Adds a new session and returns it</summary>
		/// <param name="sessionId"></param>
		public override IArchivingSession AddSession(string sessionId)
		{
			// look for existing session
			foreach (var sess in _imdiData.Sessions.Where(sess => sess.Name == sessionId))
				return sess;

			// if not found, add a new session
			Session session = new Session {Name = sessionId};

			_imdiData.Sessions.Add(session);

			return session;
		}
示例#7
0
		/// <summary>Set the access code on session files if not set already.</summary>
		private void SetFileAccessCode(Session session)
		{
			if (string.IsNullOrEmpty(session.AccessCode)) return;

			foreach (var file in session.Resources.MediaFile)
			{
				if (file.Access == null)
					file.Access = new AccessType();

				if (string.IsNullOrEmpty(file.Access.Availability))
					file.Access.Availability = session.AccessCode;
			}

			foreach (var file in session.Resources.WrittenResource)
			{
				if (file.Access == null)
					file.Access = new AccessType();

				if (string.IsNullOrEmpty(file.Access.Availability))
					file.Access.Availability = session.AccessCode;
			}
		}
示例#8
0
		private void ArbilCheckSession(Session session)
		{
			if (session.Date == null)
				session.SetDate(DateTime.Today);

			if (session.MDGroup.Project.Count == 0)
				session.MDGroup.Project.Add(new Project());

			session.MDGroup.Content.CheckRequiredFields();

			foreach (var actor in session.MDGroup.Actors.Actor)
			{
				if (actor.Role == null)
					actor.Role = string.Empty.ToVocabularyType(false, ListType.Link(ListType.ActorRole));

				if (actor.FamilySocialRole == null)
					actor.FamilySocialRole = string.Empty.ToVocabularyType(false, ListType.Link(ListType.ActorFamilySocialRole));

				if (actor.Anonymized == null)
					actor.Anonymized = new BooleanType { Link = ListType.Link(ListType.Boolean) };

				if (actor.Sex == null)
					actor.Sex = new VocabularyType { Type = VocabularyTypeValueType.ClosedVocabulary, Link = ListType.Link(ListType.ActorSex) };
			}

			foreach (var file in session.Resources.WrittenResource)
			{
				if (file.SubType == null)
					file.SubType = new VocabularyType { Link = ListType.Link(ListType.WrittenResourceSubType) };

				if (file.Validation == null)
					file.Validation = new ValidationType
					{
						Type = new VocabularyType{ Type = VocabularyTypeValueType.ClosedVocabulary, Link = ListType.Link(ListType.ValidationType) },
						Methodology = new VocabularyType { Type = VocabularyTypeValueType.ClosedVocabulary, Link = ListType.Link(ListType.ValidationMethodology) },
						Level = new IntegerType { Value = "Unspecified" },
						Description = new DescriptionTypeCollection { new LanguageString() }
					};

				if (file.Derivation == null)
					file.Derivation = new VocabularyType { Type = VocabularyTypeValueType.ClosedVocabulary, Link = ListType.Link(ListType.WrittenResourceDerivation) };

				if (file.Anonymized == null)
					file.Anonymized = new BooleanType { Link = ListType.Link(ListType.Boolean) };

				if (file.Access == null)
					file.Access = new AccessType();
			}

			foreach (var file in session.Resources.MediaFile)
			{
				if (file.Access == null)
					file.Access = new AccessType();
			}
		}