public void Superbruker_i_DB_returnerer_brukernavn_til_superbruker() { var dbusers = new List <Superuser> { new Superuser { Username = "******", Password = SvarbotDAL.MakeHash("1234") } } .AsQueryable(); var superUserMock = new Mock <DbSet <Superuser> >(); superUserMock.As <IQueryable <Superuser> >().Setup(m => m.Provider).Returns(dbusers.Provider); superUserMock.As <IQueryable <Superuser> >().Setup(m => m.Expression).Returns(dbusers.Expression); superUserMock.As <IQueryable <Superuser> >().Setup(m => m.ElementType).Returns(dbusers.ElementType); superUserMock.As <IQueryable <Superuser> >().Setup(m => m.GetEnumerator()).Returns(() => dbusers.GetEnumerator()); var dbMock = new Mock <SvarbotDbSys>(); dbMock.Setup(x => x.Superuser).Returns(superUserMock.Object); var dalObject = new AdminDAL(dbMock.Object); var result = dalObject.Superbruker_i_DB(new SuperuserDTO { Username = "******", Password = "******" }); Assert.AreEqual("testuser", result.Username); var result1 = dalObject.Superbruker_i_DB(new SuperuserDTO { Username = "******", Password = "******" }); Assert.IsNull(result1); }
public SvarbotBL() { dal = new SvarbotDAL(); adminbl = new AdminBL(); }