public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _friendFactory = new FriendFactory(); _member1 = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _member2 = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _friend = _friendFactory.CreateFriend(_member1, _member2); using (var uow = new UnitOfWork()) { _oldCount = uow.FriendRepository.Count(); uow.MemberRepository.Add(_member1); uow.MemberRepository.Add(_member2); uow.FriendRepository.Add(_friend); uow.PersistAll(); } using (var uow = new UnitOfWork()) { _newCount = uow.FriendRepository.Count(); _loadedFriend = uow.FriendRepository.Get(_friend.Id); } }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _friendFactory = new FriendFactory(); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _members = new List<Member>(); _friends = new List<Friend>(); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); var count = new Random().Next(2, 5); for (var i = 0; i < count; i++) { var member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); var friend = _friendFactory.CreateFriend(_member, member); _friends.Add(friend); _members.Add(member); uow.MemberRepository.Add(member); uow.FriendRepository.Add(friend); } uow.PersistAll(); } using (var uow = new UnitOfWork()) { var member = uow.MemberRepository.Get(_member.Id); _loadedFriends = uow.FriendRepository.GetFor(member); } }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _friendFactory = new FriendFactory(); _member1 = _memberFactory.CreateMember("*****@*****.**"); _member2 = _memberFactory.CreateMember("*****@*****.**"); _friend = _friendFactory.CreateFriend(_member1, _member2); }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _gomeeTargetFactory = new TargetFactory(); using (var uow = new UnitOfWork()) { _me = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _he = _memberFactory.CreateMember(Guid.NewGuid().ToString()); uow.MemberRepository.Add(_me); uow.MemberRepository.Add(_he); _hisGomees = new List<Gomee>(); _mineGomees = new List<Gomee>(); _targets = new List<Target>(); var count = new Random().Next(2, 5); for (var i = 0; i < count; i++) { var mineGomee = _gomeeFactory.CreateGomee(_me); var mineTarget = _gomeeTargetFactory.CreateGomeeTarget(_me, mineGomee); var hisGome = _gomeeFactory.CreateGomee(_he); var hisTarget1 = _gomeeTargetFactory.CreateGomeeTarget(_me, hisGome); var hisTarget2 = _gomeeTargetFactory.CreateGomeeTarget(_me, hisGome); _mineGomees.Add(mineGomee); _hisGomees.Add(hisGome); _targets.Add(mineTarget); _targets.Add(hisTarget1); _targets.Add(hisTarget2); uow.GomeeRepository.Add(mineGomee); uow.GomeeRepository.Add(hisGome); uow.TargetRepository.Add(mineTarget); uow.TargetRepository.Add(hisTarget1); uow.TargetRepository.Add(hisTarget2); } uow.PersistAll(); } using (var uow = new UnitOfWork()) { var member = uow.MemberRepository.Get(_me.Id); _loadedGomees = uow.GomeeRepository.GetTheirsFor(member); } }
public void Import(ExcelFileType fileType, Stream file) { // FIELDS THAT CANNOT BE NULL! // Reference // FirstName // LastName // Salutation // [Archived] - Not in template. try { importer.Open(file, fileType, hasHeaderRow: true); const int SheetIndex = 0; // TODO: Hard-coded for now var rowsAsKeyValuePairs = importer.GetRowsAsKeyValuePairs(SheetIndex).ToList(); AddArchivedFieldToData(rowsAsKeyValuePairs); // This is a non-null field foreach (Member member in rowsAsKeyValuePairs.Select(memberData => memberFactory.CreateMember(memberData))) { memberService.Insert(member); } InvokeImportDataCompleted(); } catch (Exception ex) { // The only exception that is explicitly thrown by the underlying code is an InvalidOperationException. // I would like to make this less catch-all, but there's probably a large number of exceptions that // could be thrown by the import code, none of which are declared in the code itself. InvokeImportErrorFailed(ex); } }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _targetFactory = new TargetFactory(); _targetDecorator = new TargetDecorator(_targetFactory, _unitOfWork.TargetRepository); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _gomee = _gomeeFactory.CreateGomee(_member); _targets = new List<Target>(); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.GomeeRepository.Add(_gomee); var count = new Random().Next(2, 5); for (var i = 0; i < count; i++) { var target = _targetFactory.CreateGomeeTarget(_member, _gomee); _targets.Add(target); uow.TargetRepository.Add(target); } uow.PersistAll(); } _loadedTargets = _targetDecorator.GetFor(_unitOfWork.GomeeRepository.Get(_gomee.Id)); }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _gomee = _gomeeFactory.CreateGomee(_member); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.GomeeRepository.Add(_gomee); uow.PersistAll(); _oldCount = uow.GomeeRepository.Count(); } using (var uow = new UnitOfWork()) { uow.GomeeRepository.Remove(uow.GomeeRepository.Get(_gomee.Id)); uow.PersistAll(); _newCount = uow.GomeeRepository.Count(); try { _loadedGomee = uow.GomeeRepository.Get(_gomee.Id); } catch (ArgumentException) { _loadedGomee = null; } } }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _email = Guid.NewGuid().ToString(); using (var uow = new UnitOfWork()) { _oldCount = uow.MemberRepository.Count(); _member = _memberFactory.CreateMember(_email); uow.MemberRepository.Add(_member); uow.PersistAll(); } using (var uow = new UnitOfWork()) { _newCount = uow.MemberRepository.Count(); try { _loadedMember = uow.MemberRepository.Get(_member.Id); } catch (Exception) { _loadedMember = null; } } }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); using (var uow = new UnitOfWork()) { _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); uow.MemberRepository.Add(_member); _gomees = new List<Gomee>(); var count = new Random().Next(2, 10); for (var i = 0; i < count; i++) { var gomee = _gomeeFactory.CreateGomee(_member); _gomees.Add(gomee); uow.GomeeRepository.Add(gomee); } uow.PersistAll(); } using (var uow = new UnitOfWork()) { var member = uow.MemberRepository.Get(_member.Id); _mineGomees = uow.GomeeRepository.GetMineFor(member); } }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _targetFactory = new TargetFactory(); _targetDecorator = new TargetDecorator(_targetFactory, _unitOfWork.TargetRepository); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _gomee = _gomeeFactory.CreateGomee(_member); _target = _targetFactory.CreateGomeeTarget(_member, _gomee); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.GomeeRepository.Add(_gomee); uow.TargetRepository.Add(_target); uow.PersistAll(); _oldCount = uow.TargetRepository.Count(); } _targetDecorator.Remove(_unitOfWork.TargetRepository.Get(_target.Id)); _unitOfWork.PersistAll(); _newCount = _unitOfWork.TargetRepository.Count(); try { _loadedTarget = _unitOfWork.TargetRepository.Get(_target.Id); } catch (ArgumentException) { _loadedTarget = null; } }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _factory = new MemberFactory(); _decorator = new MemberDecorator(_factory, _unitOfWork.MemberRepository); _member = _factory.CreateMember(Guid.NewGuid().ToString()); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.PersistAll(); _oldCount = uow.MemberRepository.Count(); } _decorator.Remove(_unitOfWork.MemberRepository.Get(_member.Id)); _unitOfWork.PersistAll(); _newCount = _unitOfWork.MemberRepository.Count(); try { _loadedMember = _unitOfWork.MemberRepository.Get(_member.Id); } catch (ArgumentException) { _loadedMember = null; } }
public When_creating_gomee() { _memberFactory = new MemberFactory(); _member = _memberFactory.CreateMember("*****@*****.**"); _gomeeFactory = new GomeeFactory(); _gomee = _gomeeFactory.CreateGomee(_member); }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _gomeeDecorator = new GomeeDecorator(_gomeeFactory, _unitOfWork.GomeeRepository); _member = _memberFactory.CreateMember("*****@*****.**"); _gomee = _gomeeDecorator.CreateGomee(_member); }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _factory = new MemberFactory(); _decorator = new MemberDecorator(_factory, _unitOfWork.MemberRepository); _member = _factory.CreateMember(Guid.NewGuid().ToString()); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.PersistAll(); } _loadedMember = _decorator.Get(_member.Id); }
public static void SetUp(TestContext context) { _memberFactory = new MemberFactory(); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.PersistAll(); } using (var uow = new UnitOfWork()) { _loadedMember = uow.MemberRepository.Get(_member.Id); } }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _gomeeDecorator = new GomeeDecorator(_gomeeFactory, _unitOfWork.GomeeRepository); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _gomee = _gomeeFactory.CreateGomee(_member); _oldCount = _unitOfWork.GomeeRepository.Count(); _unitOfWork.MemberRepository.Add(_member); _gomeeDecorator.Add(_gomee); _unitOfWork.PersistAll(); using (var uow = new UnitOfWork()) { _newCount = uow.GomeeRepository.Count(); _loadedGomee = uow.GomeeRepository.Get(_gomee.Id); } }
public static void SetUp(TestContext context) { _unitOfWork = new UnitOfWork(); _memberFactory = new MemberFactory(); _gomeeFactory = new GomeeFactory(); _targetFactory = new TargetFactory(); _targetDecorator = new TargetDecorator(_targetFactory, _unitOfWork.TargetRepository); _member = _memberFactory.CreateMember(Guid.NewGuid().ToString()); _gomee = _gomeeFactory.CreateGomee(_member); _target = _targetFactory.CreateGomeeTarget(_member, _gomee); using (var uow = new UnitOfWork()) { uow.MemberRepository.Add(_member); uow.GomeeRepository.Add(_gomee); uow.TargetRepository.Add(_target); uow.PersistAll(); } _loadedTarget = _targetDecorator.Get(_target.Id); }
public void ReturnAMemberWithTheReferencePropertySet_WhenTheInputDataContainsAReferenceProperty() { const string Reference = "SFJ458-AD2"; var data = new Dictionary <string, object> { { "Reference", Reference } }; Member member = factory.CreateMember(data); Assert.AreEqual(Reference, member.Reference); }