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 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); }
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); }