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 GomeeResponse AddGomee( Int32 memberId, String caption, String address, String description, Double latitude, Double longitude, Int32 type) { _serviceContext.ContentType = "text/html"; if (caption == null) throw FaultFactory.CreateFaultException( new ArgumentFault() { Argument = "caption", Message = String.Format( CultureInfo.InvariantCulture, Resources.ArgumentNull_String, "caption"), Value = caption }); if (address == null) throw FaultFactory.CreateFaultException( new ArgumentFault() { Argument = "address", Message = String.Format( CultureInfo.InvariantCulture, Resources.ArgumentNull_String, "address"), Value = address }); if (description == null) throw FaultFactory.CreateFaultException( new ArgumentFault() { Argument = "description", Message = String.Format( CultureInfo.InvariantCulture, Resources.ArgumentNull_String, "description"), Value = description }); GomeeResponse response = new GomeeResponse(); IUnitOfWork uow = null; IGomeeFactory factory = null; try { uow = new UnitOfWork(); factory = new GomeeFactory(); var member = uow.MemberRepository.Get(memberId); var gomee = factory.CreateGomee(member); gomee.Caption = caption; gomee.Address = address; gomee.Description = description; gomee.Latitude = latitude; gomee.Longitude = longitude; gomee.GomeeType = type; uow.GomeeRepository.Add(gomee); uow.PersistAll(); response.Id = gomee.Id; response.MemberId = gomee.Member.Id; response.Caption = gomee.Caption; response.Address = gomee.Address; response.Description = gomee.Description; response.Latitude = gomee.Latitude; response.Longitude = gomee.Longitude; response.Type = gomee.GomeeType; } catch (ArgumentException) { throw FaultFactory.CreateFaultException( new ArgumentFault() { Argument = "memberId", Message = String.Format( CultureInfo.InvariantCulture, Resources.EntityNotExist_String, "Member"), Value = memberId.ToString(CultureInfo.InvariantCulture) }); } finally { if (uow != null) { uow.Close(); } } return response; }