public void TestUpdateProfile_ExceptionDuringRemoveImage() { InternalBodyArchitectService tmp = new InternalBodyArchitectService(Session); string folder = tmp.ImagesFolder; Guid pictureId = Guid.NewGuid(); var file = File.CreateText(Path.Combine(folder, pictureId.ToString())); profiles[0].Picture = new Picture(pictureId, "dfgdfgdfg"); insertToDatabase(profiles[0]); UnitTestHelper.SetProperty(profiles[0].Tag, "Version", profiles[0].Version); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = SecurityManager.CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Profile.Picture = null; d.Profile.Gender = Gender.Male; service.UpdateProfile(data.Token, d); }); Assert.IsTrue(File.Exists(Path.Combine(folder, pictureId.ToString()))); var dbProfile = Session.Get <Profile>(profile.Id); Assert.AreEqual(Model.Gender.Male, dbProfile.Gender); file.Close(); }
protected void RunServiceMethod(Action <InternalBodyArchitectService> method) { var serviceSession = sessionFactory.OpenSession(); using (serviceSession) { var service = new InternalBodyArchitectService(serviceSession, SecurityManager, new MockEmailService(), new MockPushNotificationService()); service.ImagesFolder = ImagesFolder; NHibernateContextExtension wcfExtencsion = new NHibernateContextExtension(serviceSession); NHibernateContext.UnitTestContext = wcfExtencsion; method(service); } Session.Clear(); }
protected void RunServiceMethod(Action <InternalBodyArchitectService> method) { var serviceSession = sessionFactory.OpenSession(); using (serviceSession) { timerService = new MockTimerService(); ServiceConfiguration config = new ServiceConfiguration(timerService); config.MethodInvoker = new NormalMethodInvoker(); config.Payments = paymentsManager; var service = new InternalBodyArchitectService(serviceSession, SecurityManager, new MockEmailService(), new MockPushNotificationService(), config); service.Configuration.ImagesFolder = ImagesFolder; NHibernateContextExtension wcfExtencsion = new NHibernateContextExtension(serviceSession); NHibernateContext.UnitTestContext = wcfExtencsion; method(service); } Session.Clear(); }
public void WaitCallback(Object state) { var client = new ClientInformation(); client.Version = Const.ServiceVersion; client.ApplicationLanguage = "pl"; client.ClientInstanceId = Guid.NewGuid(); client.Platform = PlatformType.Windows; client.PlatformVersion = "1.0"; client.ApplicationVersion = "1.0.0.0"; for (int i = 0; i < 15; i++) { var session = NHibernateFactory.OpenSession(); InternalBodyArchitectService service = new InternalBodyArchitectService(session); var sessionData = service.Login(client, "kox", "kwazar".ToSHA1Hash()); session.Close(); } }
public void TestDeleteProfile_RemoveImage() { InternalBodyArchitectService tmp = new InternalBodyArchitectService(Session); string folder = tmp.ImagesFolder; Guid pictureId = Guid.NewGuid(); File.CreateText(Path.Combine(folder, pictureId.ToString())).Close(); profiles[0].Picture = new Picture(pictureId, "dfgdfgdfg"); insertToDatabase(profiles[0]); ProfileDTO profile1 = (ProfileDTO)profiles[0].Tag; SessionData data = SecurityManager.CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { service.DeleteProfile(data.Token, profile1); }); var profile = Session.Get <Profile>(profiles[0].Id); Assert.AreEqual(0, profile.FavoriteUsers.Count); Assert.AreEqual(0, profile.FavoriteWorkoutPlans.Count); Assert.IsFalse(File.Exists(Path.Combine(folder, pictureId.ToString()))); }