public void Create_Should_ReturnNewDbContextInstance() { // Arrange & Act var newContext = SqlDbContext.Create(); // Assert Assert.IsNotNull(newContext); Assert.IsInstanceOf <ISqlDbContext>(newContext); }
public async Task <IHttpActionResult> Post([FromBody] Message message) { ServiceLogic serviceLogic = new ServiceLogic(); var userManager = new ApplicationUserManager(new UserStore <ApplicationUserEntity>(SqlDbContext.Create())); var userFromTask = await userManager.FindByNameAsync(User.Identity.Name); var userToTask = await userManager.FindByNameAsync(message.UserNameTo); serviceLogic.SendMessage(userFromTask.Id, userToTask.Id, DateTime.Now, message.MessageText); return(Ok()); }
public async Task <IEnumerable <MessageResponse> > Get(string userNameTo, string dateFrom) { ServiceLogic serviceLogic = new ServiceLogic(); var userManager = new ApplicationUserManager(new UserStore <ApplicationUserEntity>(SqlDbContext.Create())); var currentUserTask = await userManager.FindByNameAsync(User.Identity.Name); var userToTask = await userManager.FindByNameAsync(userNameTo); return(serviceLogic.Get(currentUserTask.Id, userToTask.Id, DateTime.Parse(dateFrom))); }