public MarqueurControllerTests()
        {
            var options = new DbContextOptionsBuilder <MaBd>()
                          .UseInMemoryDatabase("DatabaseMarqueur-" + $"{Guid.NewGuid()}")
                          .Options;

            var bdEnMemoire = new MaBd(options);

            _marqueurControlleur = new MarqueurController(bdEnMemoire, null);
            _profilController    = new ProfilController(bdEnMemoire);

            profils.Nom         = "bla";
            profils.Courriel    = "*****@*****.**";
            profils.Prenom      = "blob";
            profils.ProfilImage = "";
            profils.Username    = "******";

            marqueur               = new Marqueur();
            marqueur.Id            = 0;
            marqueur.Nom           = "woot";
            marqueur.Desc          = "ben oui woot";
            marqueur.Icone         = 0;
            marqueur.Latitude      = 46.987m;
            marqueur.Longitude     = -71.256m;
            marqueur.Trajetlat     = "lat";
            marqueur.Trajetlng     = "lng";
            marqueur.profilId      = 0;
            marqueur.Difficulte    = 0;
            marqueur.BanqueImage   = "";
            marqueur.ImageMarqueur = "";
            marqueur.ServicesRando = "";
        }
예제 #2
0
        public void PUT_Bruker_Not_Found()
        {
            Profil nyBruker   = new Profil();
            var    commandBus = new Mock <IBrukerLogikk>();

            commandBus.Setup(c => c.EndreBrukerInfo(nyBruker, It.IsAny <string>())).Returns(false);
            // Mapper.CreateMap<CategoryFormModel, CreateOrUpdateCategoryCommand>();
            var httpConfiguration = new HttpConfiguration();

            WebApiConfig.Register(httpConfiguration);
            var httpRouteData = new HttpRouteData(httpConfiguration.Routes["DefaultApi"],
                                                  new HttpRouteValueDictionary {
                { "controller", "Profil" }
            });
            var controller = new ProfilController(commandBus.Object)
            {
                Request = new HttpRequestMessage(HttpMethod.Put, "http://localhost/api/Profil/")
                {
                    Properties =
                    {
                        { HttpPropertyKeys.HttpConfigurationKey, httpConfiguration },
                        { HttpPropertyKeys.HttpRouteDataKey,     httpRouteData     }
                    }
                }
            };
            // Act
            var response = controller.Put(nyBruker);

            // Assert
            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
            // var newCategory = JsonConvert.DeserializeObject<CategoryModel>(response.Content.ReadAsStringAsync().Result);
        }
예제 #3
0
        public void OcjenjivanjeTest()
        {
            int ClanID     = 2;
            int ocjena     = 1;
            int teretanaID = 4;

            //var optionsBuilder = new DbContextOptionsBuilder<MyContext>()
            //    .UseInMemoryDatabase(Guid.NewGuid().ToString());

            //var _dbContext = new MyContext(optionsBuilder.Options);
            ProfilController controller = new ProfilController();
            int ocjenaClana             = controller.OcijeniTest(ClanID, ocjena, teretanaID);

            Assert.AreEqual(1, ocjenaClana);
        }
예제 #4
0
        public void UrediProfilTest()
        {
            UrediProfilVM model = new UrediProfilVM();

            model.ClanID        = 3;
            model.KorisnickoIme = "amina1";
            model.Lozinka       = "123";

            //var optionsBuilder = new DbContextOptionsBuilder<MyContext>()
            //    .UseInMemoryDatabase(Guid.NewGuid().ToString());

            //var _dbContext = new MyContext(optionsBuilder.Options);
            ProfilController controller = new ProfilController();
            int clanRezultat            = controller.UrediSnimiTest(model);

            Assert.AreEqual(3, clanRezultat);
        }
예제 #5
0
        public void PUT_Bruker_Bad_request()
        {
            var commandBus = new Mock <IBrukerLogikk>();

            commandBus.Setup(c => c.EndreBrukerInfo(It.IsAny <Profil>(), It.IsAny <string>())).Returns(true);
            // Mapper.CreateMap<CategoryFormModel, CreateOrUpdateCategoryCommand>();
            var httpConfiguration = new HttpConfiguration();

            WebApiConfig.Register(httpConfiguration);
            var httpRouteData = new HttpRouteData(httpConfiguration.Routes["DefaultApi"],
                                                  new HttpRouteValueDictionary {
                { "controller", "Profil" }
            });
            var controller = new ProfilController(commandBus.Object)
            {
                Request = new HttpRequestMessage(HttpMethod.Put, "http://localhost/api/Profil/")
                {
                    Properties =
                    {
                        { HttpPropertyKeys.HttpConfigurationKey, httpConfiguration },
                        { HttpPropertyKeys.HttpRouteDataKey,     httpRouteData     }
                    }
                }
            };
            Profil nyBruker = new Profil();

            nyBruker.Fornavn = "";
            // The ASP.NET pipeline doesn't run, so validation don't run.
            controller.ModelState.AddModelError("Fornavn", "mock error message");
            var response = controller.Put(nyBruker);

            // Assert
            commandBus.Verify(e => e.EndreBrukerInfo(nyBruker, "brukernavn"), Times.Never);
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            // Act
        }