public void SigleReferenceSuggestionsActionCanNotTest() { using (WebActionExecutor executor = new WebActionExecutor()) { //we add Adriano in db TestContentType adriano = TestContentType.getARandomTestContentType(enforce_a_reference: true); ContentsDatabase db = this.getGlobalObject <ContentsDatabase>(); db.Add(adriano); //we became not admin MysterySession session = this.getGlobalObject <MysterySession>(); var was_adim = session.authenticated_user.account_type == UserType.admin; if (was_adim) { session.authenticated_user.account_type = UserType.normal; } var result = executor.executeAction( new SigleReferenceSuggestionsAction(), new PropertyEditSuggestionsActionInput { content_reference = new Mystery.Content.ContentReference(adriano), property_name = nameof(TestContentType.not_ediatable_reference), search_text = null }); Assert.IsTrue(!result.isSuccessfull && result.UnAuthorized); if (was_adim) { session.authenticated_user.account_type = UserType.admin; } } }
public void ContentServiceContentViewTest() { var c = TestContentType.getARandomTestContentType(enforce_a_reference: true); var cd = this.getGlobalObject <IContentDispatcher>(); cd.Add(c); cd.AddContents(c.single_reference.getAsContentEnum()); cd.AddContents(c.multi_reference.getAsContentEnum()); var uid = c.guid.Tiny(); var s = new ContentService(); var service_result = s.ContentView(nameof(TestContentType), uid); var converter = this.getGlobalObject <IMysteryJsonUiConverter>(); var cui = converter.readJson <ContentUi>(service_result.json_output); foreach (PropertyView property_view in typeof(TestContentType).getMysteryPropertyAttributes <PropertyView>()) { var cp = property_view.used_in.getMysteryAttribute <ContentProperty>(); string name = cp == null ? property_view.used_in.Name : cp.name; Assert.IsTrue(cui.propertiesUi.ContainsKey(name)); Assert.AreEqual(cui.propertiesUi[name].content.property_name, name); } Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_string)].content.property_value, c.a_string); Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_integer)].content.property_value, c.a_integer); Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_double)].content.property_value, c.a_double); Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_boolean)].content.property_value, c.a_boolean); Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_enum)].content.property_value.ToString(), c.a_enum.ToString()); }
public void MongoContentCollectionContainsTest() { var collection = new MongoContentCollection <TestContentType>(); var probe = TestContentType.getARandomTestContentType(enforce_a_reference: false); Assert.IsFalse(collection.Contains(probe)); collection.Add(probe); Assert.IsTrue(collection.Contains(probe)); }
public void containsTypeTest() { IContentContainer container = getContainer(); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); Assert.IsFalse(container.ContainsType <TestContentType>()); container.Add(c); Assert.IsTrue(container.ContainsType <TestContentType>()); }
public void MongoContentCollectionAddTest() { var collection = new MongoContentCollection <TestContentType>(); collection.Clear(); var probe = TestContentType.getARandomTestContentType(enforce_a_reference: false); collection.Add(probe); Assert.IsFalse(collection.isEmpty); }
public void MongoContentCollectionGetContentTest() { var collection = new MongoContentCollection <TestContentType>(); var probe = TestContentType.getARandomTestContentType(enforce_a_reference: false); collection.Add(probe); var back_from_collection = collection.GetContent(probe.guid); Assert.IsTrue(back_from_collection.samePropertiesValue(probe)); }
public void addContentsTest() { IContentContainer container = getContainer(); List <IContent> contents = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); Assert.AreEqual(container.Count, contents.Count); }
public void MongoContentCollectionAddContentsTest() { var collection = new MongoContentCollection <TestContentType>(); collection.Clear(); collection.AddContents(from x in Enumerable.Range(0, 10) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); Assert.IsTrue(collection.Count == 10); }
public void WebContentDispatchercontainsTypeTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); Assert.IsFalse(container.ContainsType <TestContentType>()); container.Add(c); Assert.IsTrue(container.ContainsType <TestContentType>()); container.Dispose(); }); }
public void WebContentDispatcherAddTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); container.Add(c); Guid guid = c.guid; Assert.AreSame(c, container.GetContent <TestContentType>(guid)); container.Dispose(); return(guid.Tiny()); }); }
public void getLightContentRerefereceTest() { using (WebActionExecutor executor = new WebActionExecutor()) { IContentContainer container = getContainer(); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); container.Add(c); LightContentReferece light_reference = container.GetLightContentRereferece <TestContentType>().FirstOrDefault(); Assert.AreEqual(light_reference.ReferenceText, c.ReferenceText); Assert.AreEqual(light_reference.guid, c.guid); } }
public void RemoveTest() { using (WebActionExecutor executor = new WebActionExecutor()) { IContentContainer container = getContainer(); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); container.Add(c); Assert.IsTrue(container.Remove(c)); c = TestContentType.getARandomTestContentType(enforce_a_reference: false); Assert.IsFalse(container.Remove(c)); Assert.AreEqual(container.Count, 0); } }
public void WebContentDispatcheraddContentsTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); List <IContent> contents = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); Assert.AreEqual(container.Count, contents.Count); container.Dispose(); }); }
public void WebContentDispatcherRetriveFromPermanetTest() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); storage.Add(c); Guid guid = c.guid; Assert.IsNotNull(container.GetContent <TestContentType>(c.guid)); container.Dispose(); }); }
public void WebContentDispatchersearchTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); List <TestContentType> contents = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); Assert.IsTrue(container.Search(contents[0].the_reference_text, 10).Count() == 1); Assert.IsTrue(container.Search(contents[0].the_reference_text.Replace("-", " "), 10).Count() >= 1); Assert.IsTrue(container.Search(contents[0].the_reference_text.Split('-')[0], 10).Count() >= 1); container.Dispose(); }); }
public void getAllByFilterTest() { using (WebActionExecutor executor = new WebActionExecutor()){ IContentContainer container = getContainer(); List <TestContentType> contents = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); Assert.IsTrue(container.GetAllByFilter <TestContentType>( x => x.a_string == contents[0].a_string || x.a_string == contents[1].a_string) .sameContents(contents.Take(2))); } }
public void MongoContentCollectionGetAllTest() { var collection = new MongoContentCollection <TestContentType>(); collection.Clear(); var contents = new List <TestContentType>( from x in Enumerable.Range(0, 10) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); collection.AddContents(contents); var basket_one = new MultiContentReference <TestContentType>(contents); var basket_two = new MultiContentReference <TestContentType>(collection.GetAll().Cast <TestContentType>()); Assert.AreEqual(basket_one, basket_two); }
public void MongoContentCollectionRemoveContentsTest() { var collection = new MongoContentCollection <TestContentType>(); collection.Clear(); var probe = TestContentType.getARandomTestContentType(enforce_a_reference: false); var contents = new List <IContent>(from x in Enumerable.Range(0, 10) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); contents.Add(probe); collection.AddContents(contents); Assert.IsTrue(collection.Contains(probe)); collection.Remove(probe); Assert.IsFalse(collection.Contains(probe)); }
public void WebContentDispatchergetAllByFilterTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); List <TestContentType> contents = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); Assert.IsTrue(container.GetAllByFilter <TestContentType>( x => x.a_string == contents[0].a_string || x.a_string == contents[1].a_string) .sameContents(contents.Take(2))); container.Dispose(); }); }
public void ContentServiceContentTest() { var c = TestContentType.getARandomTestContentType(enforce_a_reference: false); //let's avoid single reference c.single_reference = new ContentReference <TestContentType>(); ContentsDatabase db = this.getGlobalObject <ContentsDatabase>(); db.Add(c); db.AddContents(c.multi_reference.getAsContentEnum()); var uid = c.guid.Tiny(); var s = new ContentService(); var service_result = s.ContentView(nameof(TestContentType), uid); var converter = this.getGlobalObject <IMysteryJsonUiConverter>(); Assert.IsTrue(converter.readJson <IContent>(service_result.json_output) is TestContentType); }
public void GetEnumeratorTest() { using (WebActionExecutor executor = new WebActionExecutor()) { IContentContainer container = getContainer(); List <TestContentType> contents = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); int tot = 0; foreach (IContent c in container) { tot += 1; } Assert.AreEqual(contents.Count, tot); } }
public void SigleReferenceSuggestionsActionCanTest() { using (WebActionExecutor executor = new WebActionExecutor()) { TestContentType adriano = TestContentType.getARandomTestContentType(enforce_a_reference: true); ContentsDatabase db = this.getGlobalObject <ContentsDatabase>(); db.Add(adriano); var result = executor.executeAction( new SigleReferenceSuggestionsAction(), new PropertyEditSuggestionsActionInput { content_reference = new Mystery.Content.ContentReference(adriano), property_name = nameof(TestContentType.single_reference), search_text = null }); Assert.IsTrue(result.isSuccessfull); } }
public void MongoContentCollectionGetAllByFilterTest() { var collection = new MongoContentCollection <TestContentType>(); collection.Clear(); var contents = new List <TestContentType>( from x in Enumerable.Range(0, 10) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); for (var i = 0; i < 5; i++) { contents[i].a_string = "Pippo"; } collection.AddContents(contents); Expression <Func <TestContentType, bool> > expression = x => x.a_string == "Pippo"; Assert.IsTrue(collection.GetAllByFilter(expression).Count() == 5); }
public void AddTest() { IContentContainer container = getContainer(); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: true); container.Add(c.single_reference.value); foreach (var r in c.multi_reference) { container.Add(r.value); } container.Add(c); Guid guid = c.guid; var back_from_container = container.GetContent <TestContentType>(guid); Assert.AreEqual(c.guid, back_from_container.guid); Assert.IsTrue(c.samePropertiesValue(back_from_container)); Assert.AreEqual(c.GetType(), back_from_container.GetType()); }
public void WebContentDispatcherNoExceptionTest() { IContentDispatcher container = null; WebActionExecutor executor = null; ContentsDatabase db = this.getGlobalObject <ContentsDatabase>(); TestContentType c = null; ExecuteTest(() => { container = WebContentDispatcher.getDispatcher(); c = TestContentType.getARandomTestContentType(enforce_a_reference: false); container.Add(c); Guid guid = c.guid; executor = WebActionExecutor.current; return(guid.Tiny()); }); Assert.IsTrue(executor.status == WebActionExecutorStatus.done); Assert.IsTrue(db.Contains(c)); }
public void WebContentDispatcherStorageHaveDifferentInstaceButSameProperties() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); storage.Add(c); Guid guid = c.guid; Assert.AreNotSame(container.GetContent <TestContentType>(guid), storage.GetContent <TestContentType>(guid)); Assert.IsTrue(container.GetContent <TestContentType>(guid).samePropertiesValue(storage.GetContent <TestContentType>(guid))); container.Dispose(); }); }
public void getAllTest() { using (WebActionExecutor executor = new WebActionExecutor()) { IContentContainer container = getContainer(); container.Clear(); List <IContent> contents = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); List <IContent> type2 = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select new TestContentType2()); container.AddContents(type2); Assert.IsTrue(container.GetAll <TestContentType2>().sameContents(type2)); Assert.IsTrue(container.GetAll <TestContentType>().sameContents(type2.Union(contents))); } }
public void WebContentDispatcherWhenRemovedStorageStilHaveIt() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); this.setGlobalObject <IContentDispatcher>(container); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); storage.Add(c); Assert.IsTrue(container.Remove(c)); Assert.IsFalse(container.Contains(c)); Assert.IsTrue(storage.Contains(c)); container.Dispose(); this.setGlobalObject <IContentDispatcher>(null); }); }
public void MongoContentCollectionGetLightContentRerefereceTest() { var collection = new MongoContentCollection <TestContentType>(); collection.Clear(); var contents = new List <IContent>( from x in Enumerable.Range(0, 10) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); collection.AddContents(contents); var refs = new List <LightContentReferece>(collection.GetLightContentRereferece()); var refs_guid = new HashSet <Guid>(from x in refs select x.guid); var ref_texts = new HashSet <string>(from x in refs select x.ReferenceText); foreach (var c in contents) { Assert.IsTrue(refs_guid.Contains(c.guid)); Assert.IsTrue(ref_texts.Contains(c.ReferenceText)); } }
public void WebContentDispatchergetAllTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); this.setGlobalObject <IContentDispatcher>(container); List <IContent> contents = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select TestContentType.getARandomTestContentType(enforce_a_reference: false)); container.AddContents(contents); List <IContent> type2 = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2) select new TestContentType2()); container.AddContents(type2); Assert.IsTrue(container.GetAll <TestContentType2>().sameContents(type2)); Assert.IsTrue(container.GetAll <TestContentType>().sameContents(type2.Union(contents))); container.Dispose(); this.setGlobalObject <IContentDispatcher>(null); }); }