public AthleteDto WriteDto(Athlete athlete)
        {
            if (athlete == null)
                throw new NullReferenceException();

            var athleteDto = new AthleteDto();
            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var modelAssembler = ObjectFactory.GetInstance<IModelAssembler>();

            athleteDto.Id = athlete.Id;
            athleteDto.Nickname = athlete.Nickname;
            athleteDto.FirstName = athlete.FirstName;
            athleteDto.LastName = athlete.LastName;
            athleteDto.Gender = athlete.Gender;
            athleteDto.TrainerSizeM = athlete.TrainerSizeM;
            athleteDto.TrainerSizeW = athlete.TrainerSizeW;
            athleteDto.SpikeSizeM = athlete.SpikeSizeM;
            athleteDto.SpikeSizeW = athlete.SpikeSizeW;
            athleteDto.Notes = athlete.Notes;
            athleteDto.Status = athlete.Status;

            athleteDto.EventParticipation = new List<EventAreaDto>(Constants.Constants.ALL_EVENT_AREAS);

            foreach (var eventArea in athlete.EventAreas)
                athleteDto.EventParticipation.FirstOrDefault(x => x.EventName == eventArea.EventName).IsParticipant = true;

            foreach (var inventoryItem in athlete.Inventory)
                athleteDto.Inventory.Add(inventoryItemAssembler.WriteDto(inventoryItem));

            return athleteDto;
        }
        public void AssemblerCorrectlyReadsInventoryItemDto()
        {
            var eventAreaDto = new EventAreaDto() { EventName = Constants.EventAreas.POLE_VAULT };
            var poleVaulter = new AthleteDto() { Nickname = "poleVaulter", FirstName = "Pole", LastName = "Vaulter1", Gender = 'M', Status = "Current" };
            var modelDto = new ModelDto();
            var model = new Model();
            var inventoryItemDto = new InventoryItemDto()
                {
                    SerialNumber = 1,
                    ModelDto = modelDto,
                    SizeM = 9,
                    SizeW = 11,
                    Width = "N",
                    RequestName = "request1",
                    EventAreaAssignmentDto = eventAreaDto,
                    Status = "Requested",
                };
            var historyDto = new InventoryMovementDto() { EventType = new InventoryEventTypeDto() { EventType = Constants.InventoryEventTypes.ORDER } };

            inventoryItemDto.MovementHistory.Add(historyDto);

            _mockModelAssembler.Setup(x => x.ReadDto(modelDto)).Returns(model);
            _mockAthleteRepository.Setup(x => x.GetByNickname(It.IsAny<String>())).Returns(new Athlete());
            _mockInventoryRepository.Setup(x => x.GetBySerialNumber(inventoryItemDto.SerialNumber));
            _mockInventoryMovementAssembler.Setup(x => x.ReadDto(historyDto)).Returns(new InventoryMovement());
            _mockEventAreaAssembler.Setup(x => x.ReadDto(eventAreaDto)).Returns(new EventArea() { EventName = eventAreaDto.EventName });

            var inventoryItem = _assembler.ReadDto(inventoryItemDto);

            _mockInventoryRepository.VerifyAll();
            _mockModelAssembler.VerifyAll();
            _mockAthleteRepository.VerifyAll();
            _mockInventoryMovementAssembler.VerifyAll();
            _mockEventAreaAssembler.VerifyAll();
        }
        public void CanAddNewAthlete()
        {
            var athleteDto = new AthleteDto();
            athleteDto.Nickname = "sheredia";
            athleteDto.FirstName = "Sarah";
            athleteDto.LastName = "Heredia";
            athleteDto.Gender = 'F';
            athleteDto.TrainerSizeW = 9;
            athleteDto.SpikeSizeW = 9.5;
            athleteDto.Notes = "Some notes on Sarah";
            athleteDto.Status = "Current";

            var poleVault = new EventAreaDto() { EventName = Constants.EventAreas.POLE_VAULT, IsParticipant = true };
            var sprints = new EventAreaDto() { EventName = Constants.EventAreas.SPRINTS, IsParticipant = true };

            athleteDto.EventParticipation.Add(poleVault);
            athleteDto.EventParticipation.Add(sprints);

            AthleteService.SaveAthlete(athleteDto);

            var fromDb = ObjectFactory.GetInstance<IAthleteRepository>().GetByNickname(athleteDto.Nickname);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(athleteDto.Nickname, fromDb.Nickname);
            Assert.AreEqual(athleteDto.FirstName, fromDb.FirstName);
            Assert.AreEqual(athleteDto.LastName, fromDb.LastName);
            Assert.AreEqual(athleteDto.Gender, fromDb.Gender);
            Assert.AreEqual(athleteDto.SpikeSizeW, fromDb.SpikeSizeW);
            Assert.AreEqual(athleteDto.Notes, fromDb.Notes);
            Assert.AreEqual(athleteDto.Status, fromDb.Status);
            Assert.AreEqual(athleteDto.EventParticipation.Count, fromDb.EventAreas.Count);
        }
        public void CanGetAllEventParticipants()
        {
            var poleVaulter = new AthleteDto() { Nickname = "poleVaulter", FirstName = "Pole", LastName = "Vaulter1", Gender = 'M', Status = "Current" };
            var poleVaultingSprinter = new AthleteDto() { Nickname = "poleVaulingSprinter", FirstName = "PoleVaulting", LastName = "Sprinter", Gender = 'F', Status = "Future" };
            var sprinter = new AthleteDto() { Nickname = "sprinter", FirstName = "Sprint", LastName = "er", Gender = 'M', Status = "Past" };
            var poleVault = new EventAreaDto() { EventName = "PoleVault" };
            var sprints = new EventAreaDto() { EventName = "Sprints" };
            var modelDto = new ModelDto() { ModelNumber = "1234", ModelName = "name", Type = "runner", Color = "white", Price = 105, IsDiscontinued = false };
            var shoe1 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", StatusLastChanged = DateTime.Now };
            var shoe2 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", StatusLastChanged = DateTime.Now };
            var shoe3 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", StatusLastChanged = DateTime.Now };

            poleVaulter.EventParticipation.Add(poleVault);
            poleVaultingSprinter.EventParticipation.Add(poleVault);
            poleVaultingSprinter.EventParticipation.Add(sprints);
            sprinter.EventParticipation.Add(sprints);
            poleVaulter.Inventory.Add(shoe1);
            poleVaulter.Inventory.Add(shoe2);
            poleVaultingSprinter.Inventory.Add(shoe3);

            CoreAthleteService.SaveAthlete(poleVaulter);
            CoreAthleteService.SaveAthlete(poleVaultingSprinter);
            CoreAthleteService.SaveAthlete(sprinter);

            var poleVaultersList = CoreAthleteService.GetAllAthletesForEventArea("PoleVault");

            Assert.IsNotNull(poleVaultersList);
            Assert.AreEqual(2, poleVaultersList.Count);
            Assert.IsNotNull(poleVaultersList.ToList().First(x => x.Nickname == poleVaulter.Nickname));
            Assert.IsNotNull(poleVaultersList.ToList().First(x => x.Nickname == poleVaultingSprinter.Nickname));
            Assert.IsNull(poleVaultersList.ToList().FirstOrDefault(x => x.Nickname == sprinter.Nickname));
        }
        public static void SaveAthlete(AthleteDto athleteDto)
        {
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var athleteRepository = ObjectFactory.GetInstance<IAthleteRepository>();

            var athlete = athleteAssembler.ReadDto(athleteDto);

            athleteRepository.Save(athlete);
            athleteDto = athleteAssembler.WriteDto(athlete);
        }
        public void AssignInventoryItemToAthlete()
        {
            var newAthleteDto = new AthleteDto() { FirstName = "Jeff", LastName = "Artis-Gray", Nickname = "JArtis-Gray", Gender = 'M', TrainerSizeM = 14, TrainerSizeW = 12, SpikeSizeM = 14, SpikeSizeW = 12, Notes = "Notes about Jeff Artis-Gray", Status = "Future" };
            var newAthlete = new Athlete() { FirstName = "Jeff", LastName = "Artis-Gray", Nickname = "JArtis-Gray", Gender = 'M', TrainerSizeM = 14, TrainerSizeW = 12, SpikeSizeM = 14, SpikeSizeW = 12, Notes = "Notes about Jeff Artis-Gray", Status = "Future" };
            _mockAthleteAssembler.Setup(x => x.ReadDto(newAthleteDto)).Returns(newAthlete);

            InventoryService.AssignInventoryItemToAthlete(_inventoryItemDto, newAthleteDto, String.Empty);

            _mockAthleteAssembler.VerifyAll();
            _mockInventoryItemAssembler.VerifyAll();
            _mockInventoryItemRepository.VerifyAll();
            _mockInventoryMovementRepository.VerifyAll();
        }
 public InventoryItemDto AssignInventoryItemToAthlete(InventoryItemDto inventoryItemDto, AthleteDto athleteDto, String description)
 {
     try
     {
         return InventoryService.AssignInventoryItemToAthlete(inventoryItemDto, athleteDto, description);
     }
     catch (InvalidOperationException e)
     {
         throw new FaultException(
             new FaultReason(e.Message),
             new FaultCode(e.Message)
         );
     }
 }
        public Athlete ReadDto(AthleteDto athleteDto)
        {
            if (athleteDto == null)
                throw new NullReferenceException();

            var athlete = ObjectFactory.GetInstance<IAthleteRepository>().GetByNickname(athleteDto.Nickname);

            if (athlete == null)
                athlete = new Athlete();

            var eventAreaAssembler = ObjectFactory.GetInstance<IEventAreaAssembler>();
            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();

            foreach (var eventAreaDto in athleteDto.EventParticipation)
            {
                if (eventAreaDto.IsParticipant)
                {
                    var eventArea = eventAreaAssembler.ReadDto(eventAreaDto);

                    athlete.EventAreas.Add(eventArea);
                    eventArea.Athletes.Add(athlete);
                }
            }

            if (athleteDto.Inventory != null)
            {
                foreach (var inventoryItemDto in athleteDto.Inventory)
                {
                    var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);

                    athlete.Inventory.Add(inventoryItem);
                    inventoryItem.Athlete = athlete;
                }
            }
            else
                athlete.Inventory = new HashedSet<InventoryItem>();

            athlete.Nickname = athleteDto.Nickname;
            athlete.FirstName = athleteDto.FirstName;
            athlete.LastName = athleteDto.LastName;
            athlete.Gender = athleteDto.Gender;
            athlete.TrainerSizeM = athleteDto.TrainerSizeM;
            athlete.TrainerSizeW = athleteDto.TrainerSizeW;
            athlete.SpikeSizeM = athleteDto.SpikeSizeM;
            athlete.SpikeSizeW = athleteDto.SpikeSizeW;
            athlete.Notes = athleteDto.Notes;
            athlete.Status = athleteDto.Status;

            return athlete;
        }
        public void AssemblerCorrectlyReadsAthleteDto()
        {
            var athleteDto = new AthleteDto();
            athleteDto.Id = 123456;
            athleteDto.Nickname = "TestNickname";
            athleteDto.FirstName = "TestFirstName";
            athleteDto.LastName = "TestLastName";
            athleteDto.Gender = 'M';
            athleteDto.TrainerSizeM = 9.5;
            athleteDto.SpikeSizeM = 8.5;
            athleteDto.Notes = "Some test notes";
            athleteDto.Status = "Current";

            var eventAreaDto = new EventAreaDto();
            eventAreaDto.EventName = Constants.EventAreas.POLE_VAULT;
            eventAreaDto.IsParticipant = true;

            var modelDto = new ModelDto();
            modelDto.ModelNumber = "1234";
            modelDto.ModelName = "model name";
            modelDto.Type = "model type";
            modelDto.Price = 105.00;
            modelDto.Color = "white";
            modelDto.IsDiscontinued = false;

            var inventoryItemDto = new InventoryItemDto();
            inventoryItemDto.SerialNumber = 1;
            inventoryItemDto.ModelDto = modelDto;
            inventoryItemDto.SizeM = 9;
            inventoryItemDto.SizeW = 11;
            inventoryItemDto.Width = "N";
            inventoryItemDto.RequestName = "request1";
            inventoryItemDto.Status = "Requested";
            inventoryItemDto.StatusLastChanged = new DateTime(2012, 10, 31, 12, 0, 0);

            athleteDto.EventParticipation.Add(eventAreaDto);
            athleteDto.Inventory.Add(inventoryItemDto);

            _mockAthleteRepository.Setup(x => x.GetByNickname(athleteDto.Nickname));
            _mockEventAreaAssembler.Setup(x => x.ReadDto(eventAreaDto)).Returns(new EventArea());
            _mockInventoryItemAssembler.Setup(x => x.ReadDto(inventoryItemDto)).Returns(new InventoryItem());

            var athleteFromDb = _assembler.ReadDto(athleteDto);

            _mockAthleteRepository.VerifyAll();
            _mockEventAreaAssembler.VerifyAll();
            _mockInventoryItemAssembler.VerifyAll();
        }
        public static InventoryItemDto AssignInventoryItemToAthlete(InventoryItemDto inventoryItemDto, AthleteDto athleteDto, String description)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            var athlete = athleteAssembler.ReadDto(athleteDto);

            inventoryItemRepository.Save(inventoryItem);

            return ObjectFactory.GetInstance<IInventoryItemAssembler>().WriteDto(inventoryItem);
        }
        public static void AssignInventoryItemToAthlete(InventoryItemDto inventoryItemDto, AthleteDto athleteDto)
        {
            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            var athlete = athleteAssembler.ReadDto(athleteDto);

            inventoryItemRepository.Save(inventoryItem);

            inventoryItemDto.Status = Constants.Inventory.IN_STOCK;
            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
        }
        public void CanAddNewAthlete()
        {
            var athleteDto = new AthleteDto();
            athleteDto.Nickname = "sheredia";
            athleteDto.FirstName = "Sarah";
            athleteDto.LastName = "Heredia";
            athleteDto.Gender = 'F';
            athleteDto.TrainerSizeW = 9;
            athleteDto.SpikeSizeW = 9.5;
            athleteDto.Notes = "Some notes on Sarah";
            athleteDto.Status = "Current";

            var poleVault = new EventAreaDto() { EventName = "PoleVault" };
            var sprints = new EventAreaDto() { EventName = "Sprints" };
            var modelDto = new ModelDto() { ModelNumber = "1234", ModelName = "name", Type = "runner", Color = "white", Price = 105, IsDiscontinued = false };

            var shoe1 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", Athlete = athleteDto, StatusLastChanged = DateTime.Now };
            var shoe2 = new InventoryItemDto() { ModelDto = modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = "Requested", Athlete = athleteDto , StatusLastChanged = DateTime.Now };

            athleteDto.EventParticipation.Add(poleVault);
            athleteDto.EventParticipation.Add(sprints);
            athleteDto.Inventory.Add(shoe1);
            athleteDto.Inventory.Add(shoe2);

            CoreAthleteService.SaveAthlete(athleteDto);

            var fromDb = ObjectFactory.GetInstance<IAthleteRepository>().GetByNickname(athleteDto.Nickname);

            Assert.IsNotNull(fromDb);
            Assert.AreEqual(athleteDto.Nickname, fromDb.Nickname);
            Assert.AreEqual(athleteDto.FirstName, fromDb.FirstName);
            Assert.AreEqual(athleteDto.LastName, fromDb.LastName);
            Assert.AreEqual(athleteDto.Gender, fromDb.Gender);
            Assert.AreEqual(athleteDto.SpikeSizeW, fromDb.SpikeSizeW);
            Assert.AreEqual(athleteDto.Notes, fromDb.Notes);
            Assert.AreEqual(athleteDto.Status, fromDb.Status);
            Assert.AreEqual(athleteDto.EventParticipation.Count, fromDb.EventAreas.Count);
            Assert.AreEqual(athleteDto.Inventory.Count, fromDb.Inventory.Count);
        }
        public static void Distribute(InventoryItemDto inventoryItemDto, AthleteDto athleteDto)
        {
            if (!InventoryMovementValidator.ValidateDistribute(inventoryItemDto))
                throw new InvalidOperationException("Inventory item must have a status of in stock.");

            if (inventoryItemDto == null)
                throw new ArgumentNullException("inventoryItemDto");
            if (athleteDto == null)
                throw new ArgumentNullException("athleteDto");

            var inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            var athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();
            var inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            var inventoryMovementRepository = ObjectFactory.GetInstance<IInventoryMovementRepository>();
            var inventoryItem = inventoryItemAssembler.ReadDto(inventoryItemDto);
            var athlete = athleteAssembler.ReadDto(athleteDto);

            inventoryItemRepository.Distribute(inventoryItem, athlete);
            inventoryMovementRepository.Save(GetInventoryMovement(inventoryItem, Constants.InventoryEventTypes.DISTRIBUTE_TO_ATHLETE, "Some message"));

            inventoryItemDto.Status = Constants.Inventory.DISTRIBUTED;
            inventoryItemDto.SerialNumber = inventoryItem.SerialNumber;
        }
        public void MyAthletesPopulatesWithCorrectNumberOfAthletes()
        {
            var athletes = new AthleteDto[2];
            athletes[0] = new AthleteDto() { Nicknamek__BackingField = "Athlete1" };
            athletes[1] = new AthleteDto() { Nicknamek__BackingField = "Athlete2" };

            _mockAthleteService.Setup(x => x.GetAllAthletesForEventArea(String.Empty)).Returns(athletes);

            Assert.IsNotNull(_athleteViewModel.MyAthletes);
            Assert.AreEqual(2, _athleteViewModel.MyAthletes.Count);
        }
 public AthleteDto SaveAthlete(AthleteDto athleteDto)
 {
     return AthleteService.SaveAthlete(athleteDto);
 }
 public void Distribute(InventoryItemDto inventoryItemDto, AthleteDto athleteDto)
 {
     CoreInventoryService.Distribute(inventoryItemDto, athleteDto);
 }
        public void SaveAthlete()
        {
            #region Setup objects
            var athleteDto = new AthleteDto();
            athleteDto.Nickname = "sheredia";
            athleteDto.FirstName = "Sarah";
            athleteDto.LastName = "Heredia";
            athleteDto.Gender = 'F';
            athleteDto.TrainerSizeW = 9;
            athleteDto.SpikeSizeW = 9.5;
            athleteDto.Notes = "Some notes on Sarah";
            athleteDto.Status = "Current";

            var eventAreaDto = new EventAreaDto();
            eventAreaDto.EventName = "Pole Vault";

            var modelDto = new ModelDto();
            modelDto.ModelNumber = "1234";
            modelDto.ModelName = "Model name";
            modelDto.Type = "Runner";
            modelDto.Color = "White";
            modelDto.Price = 105.00;
            modelDto.IsDiscontinued = false;

            var inventoryItemDto = new InventoryItemDto();
            inventoryItemDto.ModelDto = modelDto;
            inventoryItemDto.SizeM = 9;
            inventoryItemDto.SizeW = 11;
            inventoryItemDto.Width = "N";
            inventoryItemDto.RequestName = "request1";
            inventoryItemDto.Status = "Requested";
            //inventoryItemDto.AthleteDto = athleteDto;
            inventoryItemDto.StatusLastChanged = DateTime.Now;

            athleteDto.EventParticipation.Add(eventAreaDto);
            athleteDto.Inventory.Add(inventoryItemDto);

            var athlete = new Athlete();
            athlete.Nickname = "sheredia";
            athlete.FirstName = "Sarah";
            athlete.LastName = "Heredia";
            athlete.Gender = 'F';
            athlete.TrainerSizeW = 9;
            athlete.SpikeSizeW = 9.5;
            athlete.Notes = "Some notes on Sarah";
            athlete.Status = "Current";

            var eventArea = new EventArea();
            eventArea.EventName = "Pole Vault";

            var model = new Model();
            model.ModelNumber = "1234";
            model.ModelName = "Model name";
            model.Type = "Runner";
            model.Color = "White";
            model.Price = 105.00;
            model.IsDiscontinued = false;

            var inventoryItem = new InventoryItem();
            inventoryItem.Model = model;
            inventoryItem.SizeM = 9;
            inventoryItem.SizeW = 11;
            inventoryItem.Width = "N";
            inventoryItem.RequestName = "request1";
            inventoryItem.Status = "Requested";
            inventoryItem.Athlete = athlete;
            inventoryItem.StatusLastChanged = DateTime.Now;

            athlete.EventAreas.Add(eventArea);
            athlete.Inventory.Add(inventoryItem);
            #endregion

            _mockAthleteAssembler.Setup(x => x.ReadDto(athleteDto)).Returns(athlete);
            _mockAthleteRepository.Setup(x => x.Save(athlete));
            _mockAthleteAssembler.Setup(x => x.WriteDto(athlete)).Returns(new AthleteDto());

            AthleteService.SaveAthlete(athleteDto);

            _mockAthleteAssembler.VerifyAll();
            _mockAthleteRepository.VerifyAll();
        }
        public void ReadDto_InitializesNewListWhenAthleteDoesNotHaveInventory()
        {
            var athleteDto = new AthleteDto();
            athleteDto.Id = 123456;
            athleteDto.Nickname = "TestNickname";
            athleteDto.FirstName = "TestFirstName";
            athleteDto.LastName = "TestLastName";
            athleteDto.Gender = 'M';
            athleteDto.TrainerSizeM = 9.5;
            athleteDto.SpikeSizeM = 8.5;
            athleteDto.Notes = "Some test notes";
            athleteDto.Status = "Current";

            var eventAreaDto = new EventAreaDto();
            eventAreaDto.EventName = Constants.EventAreas.POLE_VAULT;
            eventAreaDto.IsParticipant = true;

            athleteDto.EventParticipation.Add(eventAreaDto);

            _mockAthleteRepository.Setup(x => x.GetByNickname(athleteDto.Nickname));
            _mockEventAreaAssembler.Setup(x => x.ReadDto(eventAreaDto)).Returns(new EventArea());

            var athleteFromDb = _assembler.ReadDto(athleteDto);

            Assert.AreEqual(0, athleteFromDb.Inventory.Count);
            _mockAthleteRepository.VerifyAll();
            _mockEventAreaAssembler.VerifyAll();
        }
        public void Setup()
        {
            _model = new Model() { ModelNumber = "524395-386", ModelName = "Air Pegasus+ 29 Trail", Type = "Running", Price = 105, Color = "Silver Sage/Team Red/University Red/Total Orange", IsDiscontinued = false };
            _inventoryItem = new InventoryItem() { Model = _model, Athlete = _athlete, SizeM = 9, SizeW = 7, Width = "N", RequestName = "request1", Status = Constants.Inventory.REQUESTED, StatusLastChanged = new DateTime(2012, 8, 18, 11, 26, 13) };
            _athlete = new Athlete() { FirstName = "Jeff", LastName = "Artis-Gray", Nickname = "JArtis-Gray", Gender = 'M', TrainerSizeM = 14, TrainerSizeW = 12, SpikeSizeM = 14, SpikeSizeW = 12, Notes = "Notes about Jeff Artis-Gray", Status = "Future" };
            _athlete.Inventory.Add(_inventoryItem);
            _inventoryItem.Athlete = _athlete;

            Bootstrapper.BootstrapStructureMap();
            ObjectFactory.GetInstance<IMySessionFactory>().ExportSchema();

            _inventoryItemRepository = ObjectFactory.GetInstance<IInventoryItemRepository>();
            _athleteRepository = ObjectFactory.GetInstance<IAthleteRepository>();
            _inventoryItemAssembler = ObjectFactory.GetInstance<IInventoryItemAssembler>();
            _athleteAssembler = ObjectFactory.GetInstance<IAthleteAssembler>();

            _inventoryItemDto = _inventoryItemAssembler.WriteDto(_inventoryItem);
            _athleteDto = _athleteAssembler.WriteDto(_athlete);

            ObjectFactory.GetInstance<IModelRepository>().Save(_model);
            _athleteRepository.Save(_athlete);
            _inventoryItemRepository.Save(_inventoryItem);
            _inventoryItemDto.SerialNumber = _inventoryItem.SerialNumber;
            _athleteDto.Id = _athlete.Id;
        }
 public void SaveAthlete(AthleteDto athlete)
 {
     CoreAthleteService.SaveAthlete(athlete);
 }
        public void Setup()
        {
            _athleteDto = new AthleteDto() { Nickname = "sheredia", FirstName = "Sarah", LastName = "Heredia", Gender = 'F', TrainerSizeW = 9, SpikeSizeW = 9.5, Notes = "Some notes on Sarah", Status = "Current" };
            _modelDto = new ModelDto() { ModelNumber = "1234", ModelName = "Model name", Type = "Runner", Color = "White", Price = 105.00, IsDiscontinued = false };
            _inventoryItemDto = new InventoryItemDto() { ModelDto = _modelDto, SizeM = 9, SizeW = 11, Width = 'N', RequestName = "request1", Status = String.Empty, Athlete = _athleteDto, StatusLastChanged = DateTime.Now };
            _inventoryItemRepository = ObjectFactory.GetInstance<InventoryItemRepository>();
            _athleteDto.Inventory.Add(_inventoryItemDto);

            Bootstrapper.BootstrapStructureMap();
            ObjectFactory.GetInstance<IMySessionFactory>().ExportSchema();

            CoreAthleteService.SaveAthlete(_athleteDto);
        }
        public void Setup()
        {
            _mockInventoryItemAssembler = new Mock<IInventoryItemAssembler>();
            _mockAthleteAssembler = new Mock<IAthleteAssembler>();
            _mockModelAssembler = new Mock<IModelAssembler>();
            _mockInventoryItemRepository = new Mock<IInventoryItemRepository>();
            _mockInventoryMovementRepository = new Mock<IInventoryMovementRepository>();
            _mockModelRepository = new Mock<IModelRepository>();
            _inventoryItemDto = new InventoryItemDto() { ModelDto = new ModelDto() };
            _athleteDto = new AthleteDto();
            _modelDto = new ModelDto();
            _inventoryItem = new InventoryItem();
            _athlete = new Athlete();
            _model = new Model();

            ObjectFactory.Inject(typeof(IInventoryItemAssembler), _mockInventoryItemAssembler.Object);
            ObjectFactory.Inject(typeof(IAthleteAssembler), _mockAthleteAssembler.Object);
            ObjectFactory.Inject(typeof(IModelAssembler), _mockModelAssembler.Object);
            ObjectFactory.Inject(typeof(IInventoryItemRepository), _mockInventoryItemRepository.Object);
            ObjectFactory.Inject(typeof(IInventoryMovementRepository), _mockInventoryMovementRepository.Object);
            ObjectFactory.Inject(typeof(IModelRepository), _mockModelRepository.Object);

            _mockInventoryItemAssembler.Setup(x => x.ReadDto(_inventoryItemDto)).Returns(_inventoryItem);
        }