private void importSizes(TrainingDay day, int oldTrainingDayId, SqlCeConnection oldConnection) { Log.WriteInfo("Importing sizes for trainingdate={0},oldTrainingDayId={1}", day.TrainingDate, oldTrainingDayId); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = oldConnection; cmd.CommandText = "SELECT SpecificEntryObject_id,Wymiary_id FROM SizeEntry,EntryObject e WHERE e.Id=SpecificEntryObject_id AND e.TrainingDay_ID=" + oldTrainingDayId; var reader = cmd.ExecuteReader(); Log.WriteInfo("sizes reader executed"); while (reader.Read()) { SizeEntry entry = new SizeEntry(); entry.Wymiary = importWymiar(oldConnection, getInt32(reader, "Wymiary_id").Value); if (!entry.IsEmpty) { day.AddEntry(entry); } } reader.Close(); }
public void DeleteDayWithSystemEntry() { TrainingDay day = new TrainingDay(DateTime.Now); day.Profile = profiles[0]; SizeEntry entry = new SizeEntry(); entry.Wymiary = new Wymiary(); entry.Wymiary.Height = 100; entry.Status = Model.EntryObjectStatus.System; day.AddEntry(entry); insertToDatabase(day); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); }
public void TestDeleteTrainingDay_Mode_OnlyWithoutMyTraining_TrainingDayShouldNotChanged() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); var day = new TrainingDay(date); day.Profile = profiles[0]; SizeEntry size = new SizeEntry(); size.Wymiary = new Wymiary(); MyTraining training = new A6WTraining(); training.Name = "test"; training.Profile = day.Profile; size.MyTraining = training; day.AddEntry(size); insertToDatabase(day); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; param.Mode = DeleteTrainingDayMode.OnlyWithoutMyTraining; Service.DeleteTrainingDay(data.Token, param); }); Assert.AreEqual(1, Session.QueryOver <TrainingDay>().RowCount()); Assert.AreEqual(1, Session.QueryOver <SizeEntry>().RowCount()); }
protected StrengthTrainingEntry AddTrainingDaySet(Profile profile, Customer customer, DateTime date, Exercise exercise, params Tuple <int?, decimal?>[] sets) { var trainingDay = new TrainingDay(date); trainingDay.Customer = customer; trainingDay.Profile = profile; StrengthTrainingEntry entry = new StrengthTrainingEntry(); entry.MyPlace = GetDefaultMyPlace(profile); trainingDay.AddEntry(entry); StrengthTrainingItem item = new StrengthTrainingItem(); item.Exercise = exercise; entry.AddEntry(item); foreach (var tuple in sets) { Serie set1 = new Serie(); set1.RepetitionNumber = tuple.Item1; set1.Weight = tuple.Item2; item.AddSerie(set1); } insertToDatabase(trainingDay); return(entry); }
void importTrainingDays(int oldProfileId, Profile newProfile, SqlCeConnection oldConnection) { Log.WriteInfo("Importing training days for profile id {0}, name{1}", newProfile.Id, newProfile.Name); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = oldConnection; cmd.CommandText = "SELECT ID,TrainingDate,StartTime,EndTime,Comment,WymiaryId FROM TrainingDay WHERE ProfileId=" + oldProfileId; var reader = cmd.ExecuteReader(); Log.WriteInfo("TrainingDay reader executed"); while (reader.Read()) { int oldTrainingDayId = getInt32(reader, "ID").Value; DateTime date = getDateTime(reader, "TrainingDate").Value; Log.WriteInfo("Training day id={0},TrainingDate={1}", oldTrainingDayId, date); TrainingDay day = new TrainingDay(date); day.ProfileId = newProfile.Id; day.Comment = getString(reader, "Comment"); int?wymiaryId = getInt32(reader, "WymiaryId"); if (wymiaryId.HasValue) { Log.WriteInfo("TrainingDay has wymiary id={0}", wymiaryId.Value); SizeEntry sizeEntry = new SizeEntry(); sizeEntry.Wymiary = importWymiar(oldConnection, wymiaryId.Value); day.AddEntry(sizeEntry); //session.SaveOrUpdate(sizeEntry); } importStrengthTraining(day, oldTrainingDayId, getDateTime(reader, "StartTime"), getDateTime(reader, "EndTime"), day.Comment, oldConnection); day.Save(); Log.WriteInfo("TrainingDay saved"); } Log.WriteInfo("TrainingDay import complete"); }
public void Delete_ReminderAttachedTOEntryObject() { var reminder = CreateReminder("test", profiles[0], DateTime.UtcNow, type: ReminderType.EntryObject); TrainingDay day = new TrainingDay(DateTime.Now.Date); day.Profile = profiles[0]; SizeEntry sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Reminder = reminder; sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); insertToDatabase(day); reminder.ConnectedObject = "EntryObjectDTO:" + sizeEntry.GlobalId; insertToDatabase(reminder); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.Delete; param.ReminderItemId = reminder.GlobalId; var result = service.ReminderOperation(data.Token, param); Assert.IsNull(result); }); Assert.AreEqual(0, Session.QueryOver <ReminderItem>().RowCount()); }
public void DeleteCustomer_WithExerciseProfileData() { var customer = CreateCustomer("name", profiles[0]); var exercise = CreateExercise(Session, null, "test", "test"); var trainingDay = new TrainingDay(DateTime.Now); trainingDay.Customer = customer; trainingDay.Profile = profiles[0]; StrengthTrainingEntry entry = new StrengthTrainingEntry(); entry.MyPlace = GetDefaultMyPlace(profiles[0]); trainingDay.AddEntry(entry); StrengthTrainingItem item = new StrengthTrainingItem(); item.Exercise = exercise; entry.AddEntry(item); insertToDatabase(trainingDay); CreateExerciseRecord(exercise, profiles[0], new Tuple <int, decimal>(1, 22), trainingDay.TrainingDate, customer); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); var customerDto = customer.Map <CustomerDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { service.DeleteCustomer(data.Token, customerDto); }); Assert.That(Session.QueryOver <Customer>().RowCount(), Is.EqualTo(0)); Assert.That(Session.QueryOver <ExerciseProfileData>().RowCount(), Is.EqualTo(0)); }
protected ExerciseProfileData CreateExerciseRecord(Exercise exercise, Profile profile, Tuple <int, decimal> serie, DateTime trainingDate, Customer customer = null) { var trainingDay = new TrainingDay(trainingDate); trainingDay.Customer = customer; trainingDay.Profile = profile; StrengthTrainingEntry entry = new StrengthTrainingEntry(); entry.MyPlace = GetDefaultMyPlace(profile); trainingDay.AddEntry(entry); StrengthTrainingItem item = new StrengthTrainingItem(); item.Exercise = exercise; entry.AddEntry(item); Serie set1 = new Serie(); set1.RepetitionNumber = serie.Item1; set1.Weight = serie.Item2; item.AddSerie(set1); insertToDatabase(trainingDay); ExerciseProfileData data = new ExerciseProfileData(); data.Profile = profile; data.Customer = customer; data.Serie = set1; data.TrainingDate = trainingDate; data.Repetitions = serie.Item1; data.MaxWeight = serie.Item2; data.Exercise = exercise; insertToDatabase(data); return(data); }
public void ExerciseProfileData_RemoveMaxWeightDay_LastEntryForExercise() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); var day = new TrainingDay(DateTime.Now.Date); day.Profile = profiles[0]; var exercise = CreateExercise(Session, null, "test", "t", ExerciseType.Nogi, MechanicsType.Isolation, ExerciseForceType.Pull); var entry = new StrengthTrainingEntry(); entry.MyPlace = GetDefaultMyPlace(profiles[0]); day.AddEntry(entry); var item = new StrengthTrainingItem(); item.Exercise = exercise; entry.AddEntry(item); var serie1 = new Serie("10x10"); item.AddSerie(serie1); var serie2 = new Serie("2x40"); item.AddSerie(serie2); var serie3 = new Serie("4x20"); item.AddSerie(serie3); insertToDatabase(day); ExerciseProfileData exData = new ExerciseProfileData(); exData.Exercise = exercise; exData.Profile = profiles[0]; exData.Serie = serie2; exData.MaxWeight = 40; exData.Repetitions = 2; exData.TrainingDate = day.TrainingDate; insertToDatabase(exData); RunServiceMethod(delegate(InternalBodyArchitectService Service) { DeleteTrainingDayParam param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); exData = Session.QueryOver <ExerciseProfileData>().SingleOrDefault(); Assert.IsNull(exData); }
public override void BuildDatabase() { using (var tx = Session.BeginTransaction()) { profiles.Clear(); comments.Clear(); profiles.Add(CreateProfile(Session, "test1")); profiles.Add(CreateProfile(Session, "test2")); profiles.Add(CreateProfile(Session, "test3")); day = new TrainingDay(DateTime.Now); var entry = new BlogEntry(); day.AllowComments = true; entry.Comment = "test1"; day.AddEntry(entry); day.Profile = profiles[0]; Session.Save(day); TrainingDayComment comment = new TrainingDayComment(); comment.TrainingDay = day; comment.Comment = "t1"; comment.Profile = profiles[1]; comments.Add(comment); Session.SaveOrUpdate(comment); comment = new TrainingDayComment(); comment.TrainingDay = day; comment.Comment = "t2"; comment.Profile = profiles[0]; comments.Add(comment); Session.SaveOrUpdate(comment); comment = new TrainingDayComment(); comment.TrainingDay = day; comment.Comment = "t3"; comment.Profile = profiles[2]; comments.Add(comment); Session.SaveOrUpdate(comment); profiles[0].Friends.Add(profiles[1]); profiles[1].Friends.Add(profiles[0]); Session.Update(profiles[0]); Session.Update(profiles[1]); apiKey = new APIKey(); apiKey.ApiKey = Guid.NewGuid(); apiKey.ApplicationName = "UnitTest"; apiKey.EMail = "*****@*****.**"; apiKey.RegisterDateTime = DateTime.UtcNow; insertToDatabase(apiKey); tx.Commit(); } }
SizeEntry AddTrainingDaySize(Profile profile, Customer customer, DateTime date, Wymiary wymiary, ReportStatus reportStatus = ReportStatus.ShowInReport) { var trainingDay = new TrainingDay(date); trainingDay.Customer = customer; trainingDay.Profile = profile; var entry = new SizeEntry(); entry.Wymiary = wymiary; entry.ReportStatus = reportStatus; trainingDay.AddEntry(entry); insertToDatabase(trainingDay); return(entry); }
public void A6WEntries_TrainingNotFullyFinish() { var profile = CreateProfile("profile"); MyTraining endedTraining = new MyTraining(); endedTraining.EndDate = DateTime.UtcNow.AddDays(-1).Date; endedTraining.StartDate = DateTime.UtcNow.AddDays(-3).Date; endedTraining.TrainingEnd = TrainingEnd.Break; endedTraining.Name = "TempName"; endedTraining.PercentageCompleted = null; endedTraining.Profile = profile; insertToOldDatabase(endedTraining); var day1 = new TrainingDay(DateTime.UtcNow.AddDays(-10)); day1.Comment = "cmt"; day1.Profile = profile; var a6w1 = new A6WEntry(); a6w1.Comment = "test"; a6w1.Completed = true; a6w1.MyTraining = endedTraining; a6w1.DayNumber = 1; day1.AddEntry(a6w1); insertToOldDatabase(day1); var day2 = new TrainingDay(DateTime.UtcNow.AddDays(-10)); day2.Comment = "cmt"; day2.Profile = profile; var a6w2 = new A6WEntry(); a6w2.Comment = "test"; a6w2.MyTraining = endedTraining; a6w2.Completed = false; a6w2.DayNumber = 2; a6w2.Set1 = 2; a6w2.Set2 = 3; day2.AddEntry(a6w2); insertToOldDatabase(day2); Convert(); var dbProfile = SessionNew.QueryOver <Model.Profile>().Where(x => x.UserName == profile.UserName).SingleOrDefault(); var count = SessionNew.QueryOver <Model.A6WEntry>().RowCount(); Assert.AreEqual(count, dbProfile.Statistics.A6WEntriesCount); }
private void importStrengthTraining(TrainingDay day, int oldTrainingDayId, DateTime?startTime, DateTime?endTime, string comment, SqlCeConnection oldConnection) { Log.WriteInfo("Importing strength training for trainingdate={0},oldTrainingDayId={1}", day.TrainingDate, oldTrainingDayId); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = oldConnection; cmd.CommandText = "SELECT ID,Comment,ExerciseID,Position FROM TrainingDayEntry WHERE TrainingDayID=" + oldTrainingDayId + " ORDER BY Position"; var reader = cmd.ExecuteReader(); Log.WriteInfo("StrengthTraining reader executed"); StrengthTrainingEntry entry = new StrengthTrainingEntry(); entry.Comment = comment; entry.StartTime = startTime; entry.EndTime = endTime; while (reader.Read()) { int strengthTrainingId = getInt32(reader, "ID").Value; Log.WriteInfo("Importing strenght training id={0}", strengthTrainingId); StrengthTrainingItem item = new StrengthTrainingItem(); item.Comment = getString(reader, "Comment"); entry.AddEntry(item); item.ExerciseId = getGuid(reader, "ExerciseID").Value; SqlCeCommand serieCommand = new SqlCeCommand("SELECT * FROM Serie WHERE TrainingDayEntryID=" + strengthTrainingId, oldConnection); var serieReader = serieCommand.ExecuteReader(); Log.WriteInfo("Serie reader executed"); while (serieReader.Read()) { Serie serie = new Serie(); serie.Comment = getString(serieReader, "Comment"); serie.RepetitionNumber = getInt32(serieReader, "RepetitionNumber"); serie.Weight = getFloat(serieReader, "Weight"); serie.IsLastRepetitionWithHelp = getBoolean(serieReader, "IsLastRepetitionWithHelp").Value; serie.IsCiezarBezSztangi = getBoolean(serieReader, "IsCiezarBezSztangi").Value; Log.WriteInfo("Serie {0}", serie); item.AddSerie(serie); } } Log.WriteInfo("Strength entries count={0}", entry.Entries.Count); if (entry.Entries.Count > 0) { day.AddEntry(entry); } Log.WriteInfo("StrengthTraining import complete"); }
void createStrengthEntry(DateTime date, Profile profile, params string[] exerciseShortcut) { TrainingDay day = new TrainingDay(date); day.Profile = profile; StrengthTrainingEntry entry = new StrengthTrainingEntry(); day.AddEntry(entry); foreach (var shortcut in exerciseShortcut) { StrengthTrainingItem item = new StrengthTrainingItem(); item.ExerciseId = exercises[shortcut].GlobalId; entry.AddEntry(item); } insertToDatabase(day); }
public void TestBugWithCircuralReferences_EntryObject_TrainingDay() { var profile1 = (ProfileDTO)profiles[0].Tag; //create some training day entries var day = new TrainingDay(DateTime.Now.AddDays(-2)); day.Profile = profiles[0]; var sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 213; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(-1)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 113; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); SessionData data = SecurityManager.CreateNewSession(profile1, ClientInformation); WorkoutDaysSearchCriteria searchCriteria = new WorkoutDaysSearchCriteria(); searchCriteria.UserId = profiles[0].Id; PagedResult <TrainingDayDTO> days = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { days = Service.GetTrainingDays(data.Token, searchCriteria, new PartialRetrievingInfo() { PageSize = PartialRetrievingInfo.AllElementsPageSize }); }); Assert.AreEqual(days.Items[0], days.Items[0].Objects[0].TrainingDay); Assert.AreEqual(days.Items[1], days.Items[1].Objects[0].TrainingDay); }
private void importA6w(TrainingDay day, Profile profile, int oldTrainingDayId, SqlCeConnection oldConnection) { Log.WriteInfo("Importing a6w for trainingdate={0},oldTrainingDayId={1}", day.TrainingDate, oldTrainingDayId); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = oldConnection; cmd.CommandText = "SELECT SpecificEntryObject_id,Completed,DayNumber,Set1,Set2,Set3,MyTraining_Id FROM A6WEntry,EntryObject e WHERE e.Id=SpecificEntryObject_id AND e.TrainingDay_ID=" + oldTrainingDayId; var reader = cmd.ExecuteReader(); Log.WriteInfo("A6W reader executed"); while (reader.Read()) { int strengthTrainingId = getInt32(reader, "SpecificEntryObject_id").Value; Log.WriteInfo("Importing A6W id={0}", strengthTrainingId); A6WEntry entry = new A6WEntry(); entry.Set1 = getInt32(reader, "Set1"); entry.Set2 = getInt32(reader, "Set2"); entry.Set3 = getInt32(reader, "Set3"); entry.DayNumber = getInt32(reader, "DayNumber").Value; entry.Completed = getBoolean(reader, "Completed").Value; var myTrainingId = getGuid(reader, "MyTraining_id").Value; entry.MyTraining = importMyTraining(myTrainingId, profile, oldConnection); string entryObjectSelect = "SELECT Id,Comment,Name,ReportStatus FROM EntryObject WHERE Id=" + strengthTrainingId; SqlCeCommand entryObjectCommand = new SqlCeCommand(entryObjectSelect, oldConnection); var entryObjectReader = entryObjectCommand.ExecuteReader(); entryObjectReader.Read(); entry.Comment = getString(entryObjectReader, "Comment"); entry.Name = getString(entryObjectReader, "Name"); entry.ReportStatus = (ReportStatus)getInt32(entryObjectReader, "ReportStatus").Value; entryObjectReader.Close(); day.AddEntry(entry); } reader.Close(); Log.WriteInfo("A6W import complete"); }
public override void BuildDatabase() { using (var tx = Session.BeginTransaction()) { profiles.Clear(); profiles.Add(CreateProfile(Session, "test1")); profiles.Add(CreateProfile(Session, "test2")); profiles.Add(CreateProfile(Session, "test3")); TrainingDay day = new TrainingDay(DateTime.Now); entry = new BlogEntry(); entry.AllowComments = true; entry.Comment = "test1"; day.AddEntry(entry); day.Profile = profiles[0]; Session.Save(day); BlogComment comment = new BlogComment(); comment.BlogEntry = entry; comment.Comment = "t1"; comment.Profile = profiles[1]; Session.SaveOrUpdate(comment); comment = new BlogComment(); comment.BlogEntry = entry; comment.Comment = "t2"; comment.Profile = profiles[0]; Session.SaveOrUpdate(comment); comment = new BlogComment(); comment.BlogEntry = entry; comment.Comment = "t3"; comment.Profile = profiles[2]; Session.SaveOrUpdate(comment); profiles[0].Friends.Add(profiles[1]); profiles[1].Friends.Add(profiles[0]); Session.Update(profiles[0]); Session.Update(profiles[1]); tx.Commit(); } }
public void RemoveOldRepetitionsOnceReminders_ConnectedObjectReminder_ForCustomer() { var cust = CreateCustomer("tesst", profiles[0]); var reminderFuture = CreateReminder("test", profiles[0], DateTime.UtcNow.Date.AddDays(2)); var reminderPast = CreateReminder("test", profiles[0], DateTime.UtcNow.Date.AddDays(-3)); TrainingDay day = new TrainingDay(DateTime.Now); SizeEntry size = new SizeEntry(); size.Wymiary = new Wymiary(); day.AddEntry(size); day.Customer = cust; day.Profile = profiles[0]; size.Reminder = reminderPast; insertToDatabase(day); reminderPast.ConnectedObject = "EntryObjectDTO:" + size.GlobalId.ToString(); insertToDatabase(reminderPast); RunServiceMethod(delegate(InternalBodyArchitectService service) { service.Configuration.CurrentApiKey = key; ClientInformation info = new ClientInformation(); info.ApplicationVersion = Constants.Version; info.ApplicationLanguage = "pl"; info.Version = Const.ServiceVersion; info.ClientInstanceId = Guid.NewGuid(); string password = CryptographyHelper.ToSHA1Hash("Profile1"); service.Login(info, profiles[0].UserName, password); }); var dbReminder = Session.QueryOver <ReminderItem>().SingleOrDefault(); Assert.AreEqual(dbReminder.GlobalId, reminderFuture.GlobalId); var dbSize = Session.Get <SizeEntry>(size.GlobalId); Assert.IsNull(dbSize.Reminder); }
StrengthTrainingEntry addTrainingDaySet(Model.Old.Profile profile, DateTime date, Exercise exercise, params Tuple <int?, float?>[] sets) { var trainingDay = new TrainingDay(date); trainingDay.Profile = profile; StrengthTrainingEntry entry = new StrengthTrainingEntry(); trainingDay.AddEntry(entry); StrengthTrainingItem item = new StrengthTrainingItem(); item.ExerciseId = exercise.GlobalId; entry.AddEntry(item); foreach (var tuple in sets) { Serie set1 = new Serie(); set1.RepetitionNumber = tuple.Item1; set1.Weight = tuple.Item2; item.AddSerie(set1); } insertToOldDatabase(trainingDay); return(entry); }
public void DeleteCustomer_WithCalendarEntries() { var customer = CreateCustomer("name", profiles[0]); TrainingDay day = new TrainingDay(DateTime.Now); day.Profile = profiles[0]; day.Customer = customer; BlogEntry blogEntry = new BlogEntry(); day.AddEntry(blogEntry); insertToDatabase(day); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); var customerDto = customer.Map <CustomerDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { service.DeleteCustomer(data.Token, customerDto); }); Assert.That(Session.QueryOver <Customer>().RowCount(), Is.EqualTo(0)); Assert.That(Session.QueryOver <TrainingDay>().RowCount(), Is.EqualTo(0)); }
public void DeleteMyPlaceWithEntries() { var Place = CreateMyPlace("test", profiles[0]); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); var day = new TrainingDay(DateTime.Now.AddDays(-2)); day.Profile = profiles[0]; var entry = new StrengthTrainingEntry(); entry.MyPlace = Place; day.AddEntry(entry); insertToDatabase(day); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new MyPlaceOperationParam(); param.MyPlaceId = Place.GlobalId; param.Operation = MyPlaceOperationType.Delete; Service.MyPlaceOperation(data.Token, param); }); }
public void TestBugWithCircuralReferences_StrengthTraining() { var profile1 = (ProfileDTO)profiles[0].Tag; //create some training day entries var day = new TrainingDay(DateTime.Now.AddDays(-2)); day.Profile = profiles[0]; var sizeEntry = new StrengthTrainingEntry(); day.AddEntry(sizeEntry); var strengthItem = new StrengthTrainingItem(); sizeEntry.AddEntry(strengthItem); var set = new Serie(); strengthItem.AddSerie(set); set = new Serie(); strengthItem.AddSerie(set); strengthItem = new StrengthTrainingItem(); sizeEntry.AddEntry(strengthItem); set = new Serie(); strengthItem.AddSerie(set); set = new Serie(); strengthItem.AddSerie(set); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(-1)); day.Profile = profiles[0]; sizeEntry = new StrengthTrainingEntry(); day.AddEntry(sizeEntry); strengthItem = new StrengthTrainingItem(); sizeEntry.AddEntry(strengthItem); set = new Serie(); strengthItem.AddSerie(set); set = new Serie(); strengthItem.AddSerie(set); strengthItem = new StrengthTrainingItem(); sizeEntry.AddEntry(strengthItem); set = new Serie(); strengthItem.AddSerie(set); set = new Serie(); strengthItem.AddSerie(set); Session.Save(day); trainingDays.Add(day); SessionData data = SecurityManager.CreateNewSession(profile1, ClientInformation); WorkoutDaysSearchCriteria searchCriteria = new WorkoutDaysSearchCriteria(); searchCriteria.UserId = profiles[0].Id; PagedResult <TrainingDayDTO> days = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { days = Service.GetTrainingDays(data.Token, searchCriteria, new PartialRetrievingInfo() { PageSize = PartialRetrievingInfo.AllElementsPageSize }); }); foreach (var item in ((StrengthTrainingEntryDTO)days.Items[5].Objects[0]).Entries) { Assert.AreEqual(days.Items[5].Objects[0], item.StrengthTrainingEntry); foreach (var tSet in item.Series) { Assert.AreEqual(item, tSet.StrengthTrainingItem); } } foreach (var item in ((StrengthTrainingEntryDTO)days.Items[6].Objects[0]).Entries) { Assert.AreEqual(days.Items[6].Objects[0], item.StrengthTrainingEntry); foreach (var tSet in item.Series) { Assert.AreEqual(item, tSet.StrengthTrainingItem); } } }
public override void BuildDatabase() { profiles.Clear(); trainingDays.Clear(); using (var tx = Session.BeginTransaction()) { var profile = CreateProfile(Session, "Profile1"); profiles.Add(profile); profile = CreateProfile(Session, "Profile2"); profiles.Add(profile); profile = CreateProfile(Session, "Profile3"); profiles.Add(profile); //set friendship profiles[0].Friends.Add(profiles[1]); profiles[1].Friends.Add(profiles[0]); Session.Update(profiles[0]); Session.Update(profiles[1]); //create some training day entries var day = new TrainingDay(DateTime.Now.AddDays(-2)); day.Profile = profiles[0]; var sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 213; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(-1)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 113; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(1)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Weight = 60; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(2)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 153; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); tx.Commit(); } }
private void importStrengthTraining(TrainingDay day, int oldTrainingDayId, SqlCeConnection oldConnection) { Log.WriteInfo("Importing strength training for trainingdate={0},oldTrainingDayId={1}", day.TrainingDate, oldTrainingDayId); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = oldConnection; cmd.CommandText = "SELECT SpecificEntryObject_id,StartTime,EndTime,TrainingPlanItemId,Intensity FROM StrengthTrainingEntry,EntryObject e WHERE e.Id=SpecificEntryObject_id AND e.TrainingDay_ID=" + oldTrainingDayId; var reader = cmd.ExecuteReader(); Log.WriteInfo("StrengthTraining reader executed"); while (reader.Read()) { int strengthTrainingId = getInt32(reader, "SpecificEntryObject_id").Value; Log.WriteInfo("Importing strenght training id={0}", strengthTrainingId); StrengthTrainingEntry entry = new StrengthTrainingEntry(); entry.StartTime = getDateTime(reader, "StartTime"); entry.EndTime = getDateTime(reader, "EndTime"); entry.TrainingPlanItemId = getGuid(reader, "TrainingPlanItemId"); entry.Intensity = (Intensity)getInt32(reader, "Intensity").Value; string entryObjectSelect = "SELECT Id,Comment,Name,ReportStatus FROM EntryObject WHERE Id=" + strengthTrainingId; SqlCeCommand entryObjectCommand = new SqlCeCommand(entryObjectSelect, oldConnection); var entryObjectReader = entryObjectCommand.ExecuteReader(); entryObjectReader.Read(); entry.Comment = getString(entryObjectReader, "Comment"); entry.Name = getString(entryObjectReader, "Name"); entry.ReportStatus = (ReportStatus)getInt32(entryObjectReader, "ReportStatus").Value; entryObjectReader.Close(); string strengthItemQuery = "SELECT Id,Position,ExerciseId,TrainingPlanItemId,SuperSetGroup,Comment FROM StrengthTrainingItem WHERE StrengthTrainingEntry_id=" + strengthTrainingId; var strengthItemCommand = new SqlCeCommand(strengthItemQuery, oldConnection); var strengthItemReaer = strengthItemCommand.ExecuteReader(); while (strengthItemReaer.Read()) { int strengthItemId = getInt32(strengthItemReaer, "Id").Value; StrengthTrainingItem item = new StrengthTrainingItem(); item.Comment = getString(strengthItemReaer, "Comment"); item.ExerciseId = getGuid(strengthItemReaer, "ExerciseId").Value; item.Position = getInt32(strengthItemReaer, "Position").Value; item.SuperSetGroup = getString(strengthItemReaer, "SuperSetGroup"); item.TrainingPlanItemId = getGuid(strengthItemReaer, "TrainingPlanItemId"); entry.AddEntry(item); SqlCeCommand serieCommand = new SqlCeCommand("SELECT * FROM Serie WHERE StrengthTrainingItem_id=" + strengthItemId, oldConnection); var serieReader = serieCommand.ExecuteReader(); Log.WriteInfo("Serie reader executed"); while (serieReader.Read()) { Serie serie = new Serie(); serie.Comment = getString(serieReader, "Comment"); serie.RepetitionNumber = getInt32(serieReader, "RepetitionNumber"); serie.Weight = getFloat(serieReader, "Weight"); serie.TrainingPlanItemId = getGuid(serieReader, "TrainingPlanItemId"); serie.IsLastRepetitionWithHelp = getBoolean(serieReader, "IsLastRepetitionWithHelp").Value; serie.IsCiezarBezSztangi = getBoolean(serieReader, "IsCiezarBezSztangi").Value; Log.WriteInfo("Serie {0}", serie); item.AddSerie(serie); } } strengthItemReaer.Close(); Log.WriteInfo("Strength entries count={0}", entry.Entries.Count); if (entry.Entries.Count > 0) { day.AddEntry(entry); } } reader.Close(); Log.WriteInfo("StrengthTraining import complete"); }
public override void BuildDatabase() { profiles.Clear(); trainingDays.Clear(); customers.Clear(); customersTrainingDays.Clear(); using (var tx = Session.BeginTransaction()) { var profile = CreateProfile(Session, "Profile1"); profiles.Add(profile); profile = CreateProfile(Session, "Profile2"); profiles.Add(profile); profile = CreateProfile(Session, "Profile3"); profiles.Add(profile); //set friendship profiles[0].Friends.Add(profiles[1]); profiles[1].Friends.Add(profiles[0]); Session.Update(profiles[0]); Session.Update(profiles[1]); var myGym = CreateMyPlace("gym", profiles[0]); var customer = CreateCustomer("Cust1", profiles[0]); customers.Add(customer); customer = CreateCustomer("Cust2", profiles[0]); customers.Add(customer); customer = CreateCustomer("Cust3", profiles[1]); customers.Add(customer); //create some training day entries var day = new TrainingDay(DateTime.Now.AddDays(-2)); day.Profile = profiles[0]; var sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 213; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(-1)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 113; day.AddEntry(sizeEntry); var strength = new StrengthTrainingEntry(); strength.MyPlace = myGym; day.AddEntry(strength); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(1)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Weight = 60; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(2)); day.Profile = profiles[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 153; day.AddEntry(sizeEntry); Session.Save(day); trainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(2)); day.Profile = profiles[0]; day.Customer = customers[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 153; day.AddEntry(sizeEntry); Session.Save(day); customersTrainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(3)); day.Profile = profiles[0]; day.Customer = customers[0]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 153; day.AddEntry(sizeEntry); Session.Save(day); customersTrainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(2)); day.Profile = profiles[0]; day.Customer = customers[1]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 153; day.AddEntry(sizeEntry); Session.Save(day); customersTrainingDays.Add(day); day = new TrainingDay(DateTime.Now.AddDays(2)); day.Profile = profiles[1]; day.Customer = customers[2]; sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 153; day.AddEntry(sizeEntry); Session.Save(day); customersTrainingDays.Add(day); apiKey = new APIKey(); apiKey.ApiKey = key; apiKey.ApplicationName = "UnitTest"; apiKey.EMail = "*****@*****.**"; apiKey.RegisterDateTime = DateTime.UtcNow; insertToDatabase(apiKey); tx.Commit(); } }
public override void BuildDatabase() { using (var tx = Session.BeginTransaction()) { profiles.Clear(); profiles.Add(CreateProfile(Session, "test1")); profiles.Add(CreateProfile(Session, "test2")); profiles.Add(CreateProfile(Session, "test3")); profiles.Add(CreateProfile(Session, "test4")); profiles[0].Wymiary = new Wymiary(); profiles[0].Wymiary.Pas = 102; Session.SaveOrUpdate(profiles[0]); TrainingDay day = new TrainingDay(DateTime.Now); day.Profile = profiles[0]; StrengthTrainingEntry strengthEntry = new StrengthTrainingEntry(); StrengthTrainingItem item = new StrengthTrainingItem(); strengthEntry.AddEntry(item); item.ExerciseId = Guid.NewGuid(); Serie serie = new Serie("10x20"); item.AddSerie(serie); day.AddEntry(strengthEntry); SizeEntry sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SuplementsEntry suplementsEntry = new SuplementsEntry(); SuplementItem suplementItem = new SuplementItem(); suplementItem.SuplementId = Guid.NewGuid(); suplementItem.Name = "fdgdfg"; suplementsEntry.AddItem(suplementItem); day.AddEntry(suplementsEntry); BlogEntry blogEntry = new BlogEntry(); day.AddEntry(blogEntry); A6WEntry a6WEntry = new A6WEntry(); a6WEntry.DayNumber = 1; a6WEntry.MyTraining = new MyTraining(); a6WEntry.MyTraining.Name = "fdgdfg"; a6WEntry.MyTraining.TypeId = A6WEntry.EntryTypeId; a6WEntry.MyTraining.Profile = profiles[0]; day.AddEntry(a6WEntry); Session.Save(day); BlogComment comment = new BlogComment(); comment.BlogEntry = blogEntry; comment.Profile = profiles[1]; comment.Comment = "fgdfgd"; Session.Save(comment); comment = new BlogComment(); comment.BlogEntry = blogEntry; comment.Comment = "fgdfgd"; comment.Profile = profiles[0]; Session.Save(comment); Session.Update(blogEntry); Exercise exercise = new Exercise(Guid.NewGuid()); exercise.Profile = profiles[0]; exercise.Name = "Private"; exercise.Shortcut = "PP"; Session.Save(exercise); exercise = new Exercise(Guid.NewGuid()); exercise.Profile = profiles[0]; exercise.Name = "Public"; exercise.Shortcut = "PP"; exercise.Status = PublishStatus.Published; exercise.PublishDate = DateTime.UtcNow; Session.Save(exercise); RatingUserValue exComment = new RatingUserValue(); exComment.ProfileId = profiles[1].Id; exComment.ShortComment = "dffgdfgdf"; exComment.Rating = 2; exComment.RatedObjectId = exercise.GlobalId; Session.Save(exComment); exercise = new Exercise(Guid.NewGuid()); exercise.Profile = profiles[1]; exercise.Name = "Public1"; exercise.Shortcut = "PP1"; exercise.Status = PublishStatus.Published; exercise.PublishDate = DateTime.UtcNow; Session.Save(exercise); exComment = new RatingUserValue(); exComment.ProfileId = profiles[0].Id; exComment.ShortComment = "dffgdfgdf"; exComment.Rating = 2; exComment.RatedObjectId = exercise.GlobalId; Session.Save(exComment); TrainingPlan plan = new TrainingPlan(); plan.Profile = profiles[0]; plan.GlobalId = Guid.NewGuid(); plan.Language = "pl"; plan.Author = "dfgdfg"; plan.Name = "dfgdfg"; plan.PlanContent = "fgdgdfg"; Session.Save(plan); plan = new TrainingPlan(); plan.Profile = profiles[0]; plan.Language = "pl"; plan.GlobalId = Guid.NewGuid(); plan.Author = "dfgdfg"; plan.Status = PublishStatus.Published; plan.PublishDate = DateTime.UtcNow; plan.Name = "dfgdfg"; plan.PlanContent = "fgdgdfg"; Session.Save(plan); exComment = new RatingUserValue(); exComment.ProfileId = profiles[1].Id; exComment.ShortComment = "dffgdfgdf"; exComment.Rating = 2; exComment.RatedObjectId = plan.GlobalId; Session.Save(exComment); plan = new TrainingPlan(); plan.Profile = profiles[1]; plan.Language = "pl"; plan.GlobalId = Guid.NewGuid(); plan.Author = "dfgdfg"; plan.Status = PublishStatus.Published; plan.PublishDate = DateTime.UtcNow; plan.Name = "dfgdfg"; plan.PlanContent = "fgdgdfg"; Session.Save(plan); exComment = new RatingUserValue(); exComment.ProfileId = profiles[0].Id; exComment.ShortComment = "dffgdfgdf"; exComment.Rating = 2; exComment.RatedObjectId = plan.GlobalId; Session.Save(plan); exComment = new RatingUserValue(); exComment.ProfileId = profiles[1].Id; exComment.ShortComment = "dffgdfgdf"; exComment.Rating = 2; exComment.RatedObjectId = plan.GlobalId; Session.Save(exComment); exComment = new RatingUserValue(); exComment.ProfileId = profiles[0].Id; exComment.ShortComment = "dffgdfgdf"; exComment.Rating = 2; exComment.RatedObjectId = plan.GlobalId; Session.Save(plan); Message msg = new Message(); msg.Receiver = profiles[0]; msg.Sender = profiles[1]; msg.Topic = "dfgdfgdf"; Session.Save(msg); msg = new Message(); msg.Receiver = profiles[1]; msg.Sender = profiles[0]; msg.Topic = "dfgdfgdf"; Session.Save(msg); FriendInvitation invitation = new FriendInvitation(); invitation.Invited = profiles[0]; invitation.Inviter = profiles[2]; invitation.CreateDate = DateTime.UtcNow; Session.Save(invitation); invitation = new FriendInvitation(); invitation.Invited = profiles[3]; invitation.Inviter = profiles[0]; invitation.CreateDate = DateTime.UtcNow; Session.Save(invitation); profiles[0].Friends.Add(profiles[1]); profiles[1].Friends.Add(profiles[0]); profiles[1].Statistics.FriendsCount = 1; profiles[0].FavoriteUsers.Add(profiles[1]); profiles[1].Statistics.FollowersCount = 1; profiles[0].FavoriteWorkoutPlans.Add(plan); profiles[2].FavoriteUsers.Add(profiles[0]); Session.Update(profiles[0]); Session.Update(profiles[1]); Session.Update(profiles[2]); tx.Commit(); } }