public void Put()
        {
            using (IDataContextAsync context = new LandmarkRemarkContext())
                using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
                {
                    IRepositoryAsync <Note> repository   = new Repository <Note>(context, unitOfWork);
                    INotesService           notesService = new NotesService(repository);
                    NotesController         controller   = new NotesController(notesService, unitOfWork);

                    var response = controller.PutNote(7, new Note
                    {
                        Notes   = "Notes tested",
                        Address = "300 Eu Tong Sen St, Singapore 059816",
                        Date    = DateTime.Now,
                        Lat     = 1.279366441843M,
                        Lng     = 103.839335128002M,
                        User    = "******",
                        NoteId  = 7
                    });


                    var data = (response as dynamic).Content;
                    Assert.AreEqual(data.success, true);
                }
        }
Beispiel #2
0
        public UserServiceTests()
        {
            var options = new DbContextOptionsBuilder <LandmarkRemarkContext>()
                          .UseInMemoryDatabase(databaseName: "Database" + Guid.NewGuid().ToString())
                          .Options;

            landmarkRemarkContext = new LandmarkRemarkContext(options);
            crypto = Substitute.For <ICrypto>();
            crypto.Hash(default).ReturnsForAnyArgs(x => "Hashed" + x.Arg <string>());
Beispiel #3
0
        public RemarkServiceTests()
        {
            var options = new DbContextOptionsBuilder <LandmarkRemarkContext>()
                          .UseInMemoryDatabase(databaseName: "Database" + Guid.NewGuid().ToString())
                          .Options;

            landmarkRemarkContext = new LandmarkRemarkContext(options);
            geometryFactory       = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326);
        }
        public TestBaseFixture()
        {
            var options = new DbContextOptionsBuilder <LandmarkRemarkContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            LandmarkContext  = new LandmarkRemarkContext(options);
            DateTimeProvider = new FakeDatetimeProvider();

            CreateDataForTests(LandmarkContext);
        }
Beispiel #5
0
        // use in memory database instead of mocking for repositories test
        // ensure new context is instantiate every test , matching the
        // DI scoped life cycle
        public RepositoryTestBase()
        {
            connection = new SqliteConnection("DataSource=:memory:");
            connection.Open();
            var options = new DbContextOptionsBuilder <LandmarkRemarkContext>()
                          .UseSqlite(connection)
                          .Options;

            _landmarkRemarkContext = new LandmarkRemarkContext(options);
            _landmarkRemarkContext.Database.EnsureCreated();
        }
        public void GetNotes()
        {
            // Arrange
            using (IDataContextAsync context = new LandmarkRemarkContext())
                using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
                {
                    IRepositoryAsync <Note> repository   = new Repository <Note>(context, unitOfWork);
                    INotesService           notesService = new NotesService(repository);
                    NotesController         controller   = new NotesController(notesService, unitOfWork);

                    List <NotesModel> result = controller.GetNotes("").ToList();

                    // Assert
                    Assert.IsNotNull(result);
                    Assert.AreEqual(5, result.Count());
                    Assert.AreEqual("Notes", result.ElementAt(0).Notes);
                }
        }
        private void CreateDataForTests(LandmarkRemarkContext context)
        {
            var users = new[]
            {
                new User
                {
                    FirstName = "Steve", LastName = "Smith", UserName = "******", UserNotes = new List <Note>
                    {
                        new Note {
                            Text = "Great place to visit", Location = new Point(145.1257112, -37.9131133), AddedOn = DateTimeProvider.Now()
                        }
                    }
                },
                new User
                {
                    FirstName = "Tom", LastName = "Cruise", UserName = "******", UserNotes = new List <Note>
                    {
                        new Note
                        {
                            Text = "Great place to visit", Location = new Point(153.0272569, -27.4640302), AddedOn = DateTimeProvider.Now()
                        },
                        new Note {
                            Text = "Great food", Location = new Point(152.9986068, -27.4522202), AddedOn = DateTimeProvider.Now()
                        }
                    }
                },

                new User {
                    FirstName = "Peter", LastName = "Mccormack", UserName = "******"
                }
            };

            foreach (var user in users)
            {
                (byte[] passwordHash, byte[] passwordSalt) = CreatePasswordHash($"{user.FirstName}{user.LastName}");
                user.PasswordHash = passwordHash;
                user.PasswordSalt = passwordSalt;
            }

            context.Users.AddRange(users);
            context.SaveChanges();
        }
        public void Post()
        {
            using (IDataContextAsync context = new LandmarkRemarkContext())
                using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
                {
                    IRepositoryAsync <Note> repository   = new Repository <Note>(context, unitOfWork);
                    INotesService           notesService = new NotesService(repository);
                    NotesController         controller   = new NotesController(notesService, unitOfWork);

                    //controller.Request = new HttpRequestMessage
                    //{
                    //    RequestUri = new Uri("http://localhost/api/Notes")
                    //};
                    //controller.Configuration = new HttpConfiguration();
                    //controller.Configuration.Routes.MapHttpRoute(
                    //    name: "DefaultApi",
                    //    routeTemplate: "api/{controller}/{id}",
                    //    defaults: new { id = RouteParameter.Optional });

                    //controller.RequestContext.RouteData = new HttpRouteData(
                    //    route: new HttpRoute(),
                    //    values: new HttpRouteValueDictionary { { "controller", "notes" } });


                    IHttpActionResult response = controller.PostNote(new Note
                    {
                        Notes   = "Test",
                        Address = "Test Address",
                        Date    = DateTime.Now,
                        Lat     = 1.253565M,
                        Lng     = 125.22252M,
                        User    = "******"
                    });

                    var data = (response as dynamic).Content;
                    Assert.AreEqual(data.success, true);
                }
        }
Beispiel #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, LandmarkRemarkContext landmarkRemarkContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                //TODO:
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseSwaggerUi3(typeof(Startup).GetTypeInfo().Assembly);
            app.UseCors();
            app.UseHttpsRedirection();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });

            LandmarkRemarkInitializer.Initialize(landmarkRemarkContext);
        }
 public RemarkServices(LandmarkRemarkContext dbContext)
 {
     this.dbContext = dbContext;
 }
Beispiel #11
0
 public GetLocationDetailQuery(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public GetLocationListBasedOnUserIdQuery(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public NoteRepository(LandmarkRemarkContext context)
 {
     _context = context;
 }
 public CreateUserCommand(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public GetUserDetailBasedOnUserName(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public GetLocationListBasedOnSearchTextQuery(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public GetUserListQuery(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public UserRepositoryAsync(LandmarkRemarkContext context) : base(context)
 {
     _context = context;
 }
Beispiel #19
0
 public UserLoginQuery(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public CreateNoteCommandHandler(LandmarkRemarkContext context, ITimeProvider timeProvider)
 {
     _context      = context;
     _timeProvider = timeProvider;
 }
 public ValidateUserExistsFilterImplementation(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public GetUserDetailQuery(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
Beispiel #23
0
 public UserRepository(LandmarkRemarkContext context)
 {
     _context = context;
 }
 public GetUserByIdQueryHandler(LandmarkRemarkContext context)
 {
     _context = context;
 }
 public AuthenticateUserCommandHandler(LandmarkRemarkContext context)
 {
     _context = context;
 }
Beispiel #26
0
 public UserServices(LandmarkRemarkContext dbContext, ICrypto crypto, IConfiguration configuration)
 {
     this.dbContext     = dbContext;
     this.crypto        = crypto;
     this.configuration = configuration;
 }
 public GetNotesRequestHandler(LandmarkRemarkContext context)
 {
     _context = context;
 }
Beispiel #28
0
 public MarkerRepositoryAsync(LandmarkRemarkContext context) : base(context)
 {
 }
 public CreateLocationCommand(LandmarkRemarkContext landmarkRemarkContext)
 {
     _landmarkRemarkContext = landmarkRemarkContext;
 }
 public RepositoryAsync(LandmarkRemarkContext context)
 {
     _context = context;
 }