public void TestGetCommunityNotFound() { var connection = new SqliteConnection("Datasource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <InternalServicesDirectoryV1Context>() .UseSqlite(connection) .Options; // test a successful case using (var context = new InternalServicesDirectoryV1Context(options)) { context.Database.EnsureCreated(); context.Community.Add(new Community()); context.SaveChanges(); CommunityController controller = new CommunityController(context); var actionResult = controller.Get(2).Result; var result = actionResult as NotFoundObjectResult; Assert.IsNotNull(actionResult); Assert.AreEqual(404, result.StatusCode); Assert.AreEqual("No community from given id found.", result.Value); } } finally { connection.Close(); } }
public void Setup() { uut = new CommunityController(mockLogger.Object, mockConfiguration.Object, mockCommunityGroupRepo.Object, mockCommunityMemberRepo.Object, mockPooledBookRepo.Object); }
public void Community_get() { var node = new Mock <INode>(); node.SetupGet(n => n.Blockchain).Returns(blockchain); var controller = new CommunityController(node.Object, new NullLogger <CommunityController>()); var community = controller.Get(cryptoVoteId); Assert.IsNotNull(community); Assert.AreEqual("Crypto Vote", community.Name); }
public void Communities_list() { var node = new Mock <INode>(); node.SetupGet(n => n.Blockchain).Returns(blockchain); var controller = new CommunityController(node.Object, new NullLogger <CommunityController>()); var communities = controller.List(); Assert.IsNotNull(communities); Assert.AreEqual(2, communities.Count()); }
private void LoadDatabase() { // Initialisation de la bas de données var configurationBuilder = new ConfigurationBuilder(); IConfigurationRoot configuration = configurationBuilder.Build(); NgContext ngContext = new NgContext(configuration); // Récupération des utilisateurs CommunityController communityController = new CommunityController(new CommunityRepository(ngContext)); communityController.Get(); // Récupération des recettes IHostingEnvironment appEnvironment = null; RecettesController recettesController = new RecettesController(new RecetteRepository(ngContext), new IngredientRepository(ngContext), appEnvironment); recettesController.Get(null); }
public void TestPutCommunity() { var connection = new SqliteConnection("Datasource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <InternalServicesDirectoryV1Context>() .UseSqlite(connection) .Options; // test a successful case using (var context = new InternalServicesDirectoryV1Context(options)) { context.Database.EnsureCreated(); var community = new Community(); context.Community.Add(community); context.Community.Add(new Community()); context.Community.Add(new Community()); context.SaveChanges(); CommunityController controller = new CommunityController(context); community.CommunityId = 1; community.CommunityName = "community1"; var actionResult = controller.PutCommunity(community.CommunityId, community.ToCommunityV1DTO()).Result; var result = actionResult as NoContentResult; Assert.IsNotNull(result); Assert.AreEqual(204, result.StatusCode); } } finally { connection.Close(); } }
public void Send_community() { using (var loggerFactory = CreateLoggerFactory()) { var node = new Mock <INode>(); Community communityInNode = null; node.Setup(n => n.Add(It.IsAny <Community>())).Callback <Community>(v => communityInNode = v); var controller = new CommunityController(node.Object, loggerFactory.CreateLogger <CommunityController>()); var community = new Community { Id = Guid.NewGuid(), Name = "My Company" }; var response = controller.Post(community); Assert.AreEqual((int)HttpStatusCode.Accepted, response.StatusCode); node.Verify(n => n.Add(It.IsAny <Community>()), Times.Once); Assert.IsNotNull(communityInNode); Assert.AreEqual(community.Name, communityInNode.Name); } }
protected void saveProject(object sender, CommandEventArgs e) { Member m = Member.GetCurrentMember(); Document d; var memberHasEnoughReputation = MemberHasEnoughReputation(m); if (memberHasEnoughReputation == false) { holder.Visible = false; notallowed.Visible = true; } else { if (e.CommandName == "save") { int pId = int.Parse(e.CommandArgument.ToString()); d = new Document(pId); if ((int)d.getProperty("owner").Value == m.Id || Utils.IsProjectContributor(m.Id, d.Id)) { d.Text = tb_name.Text; d.getProperty("version").Value = tb_version.Text; d.getProperty("description").Value = tb_desc.Text; d.getProperty("stable").Value = cb_stable.Checked; d.getProperty("status").Value = tb_status.Text; d.getProperty("demoUrl").Value = tb_demoUrl.Text; d.getProperty("sourceUrl").Value = tb_sourceUrl.Text; d.getProperty("websiteUrl").Value = tb_websiteUrl.Text; d.getProperty("vendorUrl").Value = tb_purchaseUrl.Text; d.getProperty("licenseUrl").Value = tb_licenseUrl.Text; d.getProperty("licenseName").Value = tb_license.Text; d.getProperty("file").Value = dd_package.SelectedValue; d.getProperty("defaultScreenshot").Value = dd_screenshot.SelectedValue; if (dd_screenshot.SelectedIndex > -1) { d.getProperty("defaultScreenshotPath").Value = new WikiFile(int.Parse(dd_screenshot.SelectedValue)).Path; } else { d.getProperty("defaultScreenshotPath").Value = ""; } if (Request["projecttags[]"] != null) { CommunityController.SetTags(d.Id.ToString(), "project", Request["projecttags[]"].ToString()); } Node category = new Node(int.Parse(dd_category.SelectedValue)); //if we have a proper category, move the package if (category != null && category.NodeTypeAlias == "ProductGroup") { ; } { if (d.Parent.Id != category.Id) { d.Move(category.Id); } } if (d.getProperty("packageGuid") == null || string.IsNullOrEmpty(d.getProperty("packageGuid").Value.ToString())) { d.getProperty("packageGuid").Value = Guid.NewGuid().ToString(); } d.Save(); d.Publish(new User(0)); library.UpdateDocumentCache(d.Id); library.RefreshContent(); } } else { d = Document.MakeNew(tb_name.Text, new DocumentType(TypeId), new User(0), RootId); d.getProperty("version").Value = tb_version.Text; d.getProperty("description").Value = tb_desc.Text; d.getProperty("stable").Value = cb_stable.Checked; d.getProperty("demoUrl").Value = tb_demoUrl.Text; d.getProperty("sourceUrl").Value = tb_sourceUrl.Text; d.getProperty("websiteUrl").Value = tb_websiteUrl.Text; d.getProperty("licenseUrl").Value = tb_licenseUrl.Text; d.getProperty("licenseName").Value = tb_license.Text; d.getProperty("vendorUrl").Value = tb_purchaseUrl.Text; //d.getProperty("file").Value = dd_package.SelectedValue; d.getProperty("owner").Value = m.Id; d.getProperty("packageGuid").Value = Guid.NewGuid().ToString(); if (Request["projecttags[]"] != null) { CommunityController.SetTags(d.Id.ToString(), "project", Request["projecttags[]"].ToString()); d.getProperty("tags").Value = Request["projecttags[]"].ToString(); } Node category = new Node(int.Parse(dd_category.SelectedValue)); //if we have a proper category, move the package if (category != null && category.NodeTypeAlias == "ProductGroup") { ; } { if (d.Parent.Id != category.Id) { d.Move(category.Id); } } d.Save(); d.Publish(new User(0)); library.UpdateDocumentCache(d.Id); library.RefreshContent(); } Response.Redirect(library.NiceUrl(GotoOnSave)); } }