public void DeleteMaterial_UnauthorizedException_Test() { var expectedmaterial = new Material() { MaterialId = 1, SessionId = 1 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository() { GetOrganizerIdInt32 = (sessionId) => { return(organizerId); } }; IMaterialRepository materialRepository = new StubIMaterialRepository() { GetInt32 = materialId => { return(expectedmaterial); } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(100000); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new MaterialsController(materialRepository, sessionRepository); target.Delete(expectedmaterial.MaterialId); } }
public void GetAllSessions_GetResults_NotFail_Test() { int expectedEventDefinitionId = 10; bool called = false; var expected = new List <Session>() { new Session() }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository() { GetAllWithUserInfoInt32Int32 = (userId, eventId) => { Assert.AreEqual(expectedEventDefinitionId, eventId); called = true; return(expected); } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(0); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new SessionsController(sessionRepository, eventRepository); IEnumerable <Session> actual = target.GetAll(expectedEventDefinitionId); Assert.IsTrue(called); Assert.AreEqual(expected.Count, actual.Count()); } }
public void PutSession_UnauthorizedException_Test() { var expectedSession = new Session() { SessionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return(eventDefinition); } }; ISessionRepository sessionRepository = new StubISessionRepository(); using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(1000); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new SessionsController(sessionRepository, eventRepository); target.Put(expectedSession); } }
public void GetMaterials_NotFail_Test() { bool called = false; var expected = new Material() { MaterialId = 10 }; ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository() { GetInt32 = materialId => { Assert.AreEqual(expected.MaterialId, materialId); called = true; return(expected); } }; var target = new MaterialsController(materialRepository, sessionRepository); Material actual = target.Get(expected.MaterialId); Assert.IsTrue(called); }
public void GetAllMaterials_GetResults_NotFail_Test() { int expectedSessionId = 10; bool called = false; var expected = new List <Material>() { new Material() }; ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository() { GetAllInt32 = sessionId => { Assert.AreEqual(expectedSessionId, sessionId); called = true; return(expected); } }; var target = new MaterialsController(materialRepository, sessionRepository); IEnumerable <Material> actual = target.GetAllMaterials(expectedSessionId); Assert.IsTrue(called); Assert.AreEqual(expected.Count, actual.Count()); }
public void DeleteComment_UnauthorizedException_Test() { var expectedcomment = new Comment() { CommentId = 1, SessionId = 10 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository() { GetOrganizerIdInt32 = (sessionId) => { return(organizerId); } }; ICommentRepository commentRepository = new StubICommentRepository() { GetInt32 = commentId => { return(expectedcomment); } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(1000); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new CommentsController(commentRepository, sessionRepository); target.Delete(expectedcomment.CommentId); } }
public void PostComment_NotFail_Test() { bool called = false; var expectedcomment = new Comment() { CommentId = 1 }; ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository() { AddComment = comment => { Assert.AreEqual(expectedcomment.CommentId, comment.CommentId); called = true; return(expectedcomment.CommentId); } }; using (ShimsContext.Create()) { var target = new CommentsController(commentRepository, sessionRepository); var actual = target.Post(expectedcomment); Assert.IsTrue(called); Assert.AreEqual(expectedcomment.CommentId, actual); } }
public void DeleteMaterial_UnauthorizedException_Test() { var expectedmaterial = new Material() { MaterialId = 1, SessionId = 1 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository() { GetOrganizerIdInt32 = (sessionId) => { return organizerId; } }; IMaterialRepository materialRepository = new StubIMaterialRepository() { GetInt32 = materialId => { return expectedmaterial; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return 100000; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new MaterialsController(materialRepository, sessionRepository); target.Delete(expectedmaterial.MaterialId); } }
public void DeleteComment_Deleted_NotFail_Test() { bool called = false; var expectedcomment = new Comment() { CommentId = 1, SessionId = 10 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository() { DeleteInt32 = commentId => { Assert.AreEqual(expectedcomment.CommentId, commentId); called = true; }, GetOrganizerIdInt32 = commentId => { return organizerId; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return organizerId; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new CommentsController(commentRepository, sessionRepository); target.Delete(expectedcomment.CommentId); Assert.IsTrue(called); } }
public void DeleteMaterial_Deleted_NotFail_Test() { bool called = false; var expectedmaterial = new Material() { MaterialId = 1, SessionId = 1 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository() { DeleteInt32 = materialId => { Assert.AreEqual(expectedmaterial.MaterialId, materialId); called = true; }, GetOrganizerIdInt32 = materialId => { return(organizerId); } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(organizerId); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new MaterialsController(materialRepository, sessionRepository); target.Delete(expectedmaterial.MaterialId); Assert.IsTrue(called); } }
public void PutSession_ArgumentNullException_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); var target = new SessionsController(sessionRepository, eventRepository); target.Put(null); }
public void PutSessionPeriod_NotFail_Test() { int expectedSessionId = 5; int duration = 10; DateTime startTime = DateTime.Now; bool getCalled = false; bool updateCalled = false; var expectedSession = new Session() { SessionId = expectedSessionId, EventDefinitionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return(eventDefinition); } }; ISessionRepository sessionRepository = new StubISessionRepository() { GetInt32 = (sessionId) => { Assert.AreEqual(expectedSessionId, sessionId); getCalled = true; return(expectedSession); }, UpdateSession = session => { Assert.AreEqual(expectedSessionId, session.SessionId); Assert.AreEqual(duration, session.Duration); updateCalled = true; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(eventDefinition.OrganizerId); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(expectedSessionId, startTime.ToString(), duration); Assert.IsTrue(getCalled); Assert.IsTrue(updateCalled); } }
public void PostMaterial_ArgumentNullException_Test() { ICommentRepository commentRepository = new StubICommentRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository(); var target = new MaterialsController(materialRepository, sessionRepository); target.Post(null); }
public void PutSessionPeriod_DurationBadParam_ExceptionExpected_Test() { int sessionId = 0; int duration = 0; DateTime startTime = DateTime.Now; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository(); var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(sessionId, startTime.ToString(), duration); }
public void DeleteSession_NotFail_Test() { bool called = false; var expectedSession = new Session() { SessionId = 1, EventDefinitionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return(eventDefinition); } }; ISessionRepository sessionRepository = new StubISessionRepository() { DeleteInt32 = sessionId => { Assert.AreEqual(expectedSession.SessionId, sessionId); called = true; }, GetInt32 = (sessionId) => { Assert.AreEqual(expectedSession.SessionId, sessionId); return(expectedSession); } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return(eventDefinition.OrganizerId); }; ShimMyEventsToken.GetTokenFromHeader = () => { return(myeventToken); }; var target = new SessionsController(sessionRepository, eventRepository); target.Delete(expectedSession.SessionId); Assert.IsTrue(called); } }
public void DeleteSession_NotFail_Test() { bool called = false; var expectedSession = new Session() { SessionId = 1, EventDefinitionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return eventDefinition; } }; ISessionRepository sessionRepository = new StubISessionRepository() { DeleteInt32 = sessionId => { Assert.AreEqual(expectedSession.SessionId, sessionId); called = true; }, GetInt32 = (sessionId) => { Assert.AreEqual(expectedSession.SessionId, sessionId); return expectedSession; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return eventDefinition.OrganizerId; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new SessionsController(sessionRepository, eventRepository); target.Delete(expectedSession.SessionId); Assert.IsTrue(called); } }
public void PutSessionPeriod_SessionNotFound_NotFail_Test() { int expectedSessionId = 5; int duration = 10; DateTime startTime = DateTime.Now; bool getCalled = false; bool updateCalled = false; var expectedSession = new Session() { SessionId = expectedSessionId }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository() { GetInt32 = (sessionId) => { Assert.AreEqual(expectedSessionId, sessionId); getCalled = true; return(null); }, UpdateSession = session => { Assert.AreEqual(expectedSessionId, session.SessionId); Assert.AreEqual(startTime, session.StartTime); Assert.AreEqual(duration, session.Duration); updateCalled = true; } }; var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(expectedSessionId, startTime.ToString(), duration); Assert.IsTrue(getCalled); Assert.IsFalse(updateCalled); }
public void GetAllComments_GetEmptyResults_NotFail_Test() { int expectedSessionId = 10; bool called = false; var expected = new List <Comment>(); ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository() { GetAllInt32 = sessionId => { Assert.AreEqual(expectedSessionId, sessionId); called = true; return(expected); } }; var target = new CommentsController(commentRepository, sessionRepository); IEnumerable <Comment> actual = target.Get(expectedSessionId); Assert.IsTrue(called); Assert.AreEqual(expected.Count, actual.Count()); }
public void SessionsController_Contructor_NotFail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); var target = new SessionsController(sessionRepository, eventRepository); }
public void PutSession_ArgumentNullException_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); var target = new SessionsController(sessionRepository, eventRepository); target.Put(null); }
public void SessionsController_ContructorSessionWithNullDependency_Fail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); var target = new SessionsController(null , eventRepository); }
public void PutSessionPeriod_SessionNotFound_NotFail_Test() { int expectedSessionId = 5; int duration = 10; DateTime startTime = DateTime.Now; bool getCalled = false; bool updateCalled = false; var expectedSession = new Session() { SessionId = expectedSessionId }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository() { GetInt32 = (sessionId) => { Assert.AreEqual(expectedSessionId, sessionId); getCalled = true; return null; }, UpdateSession = session => { Assert.AreEqual(expectedSessionId, session.SessionId); Assert.AreEqual(startTime, session.StartTime); Assert.AreEqual(duration, session.Duration); updateCalled = true; } }; var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(expectedSessionId, startTime.ToString(), duration); Assert.IsTrue(getCalled); Assert.IsFalse(updateCalled); }
public void PutSessionPeriod_UnauthorizedException_Test() { int expectedSessionId = 5; int duration = 10; DateTime startTime = DateTime.Now; var expectedSession = new Session() { SessionId = expectedSessionId, EventDefinitionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return eventDefinition; } }; ISessionRepository sessionRepository = new StubISessionRepository() { GetInt32 = (sessionId) => { Assert.AreEqual(expectedSessionId, sessionId); return expectedSession; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return 1000; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(expectedSessionId, startTime.ToString(), duration); } }
public void CommentsController_Contructor_NotFail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository(); var target = new CommentsController(commentRepository, sessionRepository); }
public void PutSessionPeriod_NotFail_Test() { int expectedSessionId = 5; int duration = 10; DateTime startTime = DateTime.Now; bool getCalled = false; bool updateCalled = false; var expectedSession = new Session() { SessionId = expectedSessionId, EventDefinitionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return eventDefinition; } }; ISessionRepository sessionRepository = new StubISessionRepository() { GetInt32 = (sessionId) => { Assert.AreEqual(expectedSessionId, sessionId); getCalled = true; return expectedSession; }, UpdateSession = session => { Assert.AreEqual(expectedSessionId, session.SessionId); Assert.AreEqual(duration, session.Duration); updateCalled = true; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return eventDefinition.OrganizerId; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(expectedSessionId, startTime.ToString(), duration); Assert.IsTrue(getCalled); Assert.IsTrue(updateCalled); } }
public void CommentsController_ContructorCommentWithNullDependency_Fail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository(); var target = new CommentsController(null, sessionRepository); }
public void GetAllMaterials_GetEmptyResults_NotFail_Test() { int expectedSessionId = 10; bool called = false; var expected = new List<Material>(); ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository() { GetAllInt32 = sessionId => { Assert.AreEqual(expectedSessionId, sessionId); called = true; return expected; } }; var target = new MaterialsController(materialRepository, sessionRepository); IEnumerable<Material> actual = target.GetAllMaterials(expectedSessionId); Assert.IsTrue(called); Assert.AreEqual(expected.Count, actual.Count()); }
public void PostMaterial_NotFail_Test() { bool called = false; var expectedmaterial = new Material() { MaterialId = 1 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository() { GetOrganizerIdInt32 = (sessionId) => { return organizerId; } }; IMaterialRepository materialRepository = new StubIMaterialRepository() { AddMaterial = material => { Assert.AreEqual(expectedmaterial.MaterialId, material.MaterialId); called = true; return expectedmaterial.MaterialId; }, GetInt32 = materialId => { return expectedmaterial; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return organizerId; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new MaterialsController(materialRepository, sessionRepository); var actual = target.Post(expectedmaterial); Assert.IsTrue(called); Assert.AreEqual(expectedmaterial.MaterialId, actual); } }
public void DeleteSession_UnauthorizedException_Test() { var expectedSession = new Session() { SessionId = 1, EventDefinitionId = 1 }; var eventDefinition = new EventDefinition() { OrganizerId = 1 }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository() { GetByIdInt32 = (id) => { Assert.AreEqual(expectedSession.EventDefinitionId, id); return eventDefinition; } }; ISessionRepository sessionRepository = new StubISessionRepository() { GetInt32 = (sessionId) => { Assert.AreEqual(expectedSession.SessionId, sessionId); return expectedSession; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return 10000; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new SessionsController(sessionRepository, eventRepository); target.Delete(expectedSession.SessionId); } }
public void PostComment_NotFail_Test() { bool called = false; var expectedcomment = new Comment() { CommentId = 1 }; ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository() { AddComment = comment => { Assert.AreEqual(expectedcomment.CommentId, comment.CommentId); called = true; return expectedcomment.CommentId; } }; using (ShimsContext.Create()) { var target = new CommentsController(commentRepository, sessionRepository); var actual = target.Post(expectedcomment); Assert.IsTrue(called); Assert.AreEqual(expectedcomment.CommentId, actual); } }
public void DeleteComment_UnauthorizedException_Test() { var expectedcomment = new Comment() { CommentId = 1, SessionId = 10 }; int organizerId = 10; ISessionRepository sessionRepository = new StubISessionRepository() { GetOrganizerIdInt32 = (sessionId) => { return organizerId; } }; ICommentRepository commentRepository = new StubICommentRepository() { GetInt32 = commentId => { return expectedcomment; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return 1000; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new CommentsController(commentRepository, sessionRepository); target.Delete(expectedcomment.CommentId); } }
public void GetAllComments_GetResults_NotFail_Test() { int expectedSessionId = 10; bool called = false; var expected = new List<Comment>() { new Comment() }; ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository() { GetAllInt32 = sessionId => { Assert.AreEqual(expectedSessionId, sessionId); called = true; return expected; } }; var target = new CommentsController(commentRepository, sessionRepository); IEnumerable<Comment> actual = target.Get(expectedSessionId); Assert.IsTrue(called); Assert.AreEqual(expected.Count, actual.Count()); }
public void MaterialsController_Contructor_NotFail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository(); var target = new MaterialsController(materialRepository, sessionRepository); }
public void PostComment_ArgumentNullException_Test() { ICommentRepository commentRepository = new StubICommentRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository(); var target = new CommentsController(commentRepository, sessionRepository); target.Post(null); }
public void SessionsController_Contructor_NotFail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); var target = new SessionsController(sessionRepository, eventRepository); }
public void GetSession_GetResult_NotFail_Test() { int expectedSessionId = 10; bool called = false; var expected = new Session() { SessionId = expectedSessionId }; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository() { GetWithUserInfoInt32Int32 = (userId, eventId) => { Assert.AreEqual(expectedSessionId, eventId); called = true; return expected; } }; using (ShimsContext.Create()) { MyEvents.Api.Authentication.Fakes.ShimMyEventsToken myeventToken = new Authentication.Fakes.ShimMyEventsToken(); myeventToken.RegisteredUserIdGet = () => { return 0; }; ShimMyEventsToken.GetTokenFromHeader = () => { return myeventToken; }; var target = new SessionsController(sessionRepository, eventRepository); Session actual = target.Get(expectedSessionId); Assert.IsTrue(called); Assert.AreEqual(expectedSessionId, actual.SessionId); } }
public void CommentsController_Contructor_NotFail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository(); var target = new CommentsController(commentRepository, sessionRepository); }
public void PutSessionPeriod_DurationBadParam_ExceptionExpected_Test() { int sessionId = 0; int duration = 0; DateTime startTime = DateTime.Now; IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); ISessionRepository sessionRepository = new StubISessionRepository(); var target = new SessionsController(sessionRepository, eventRepository); target.PutSessionPeriod(sessionId, startTime.ToString(), duration); }
public void SessionsController_ContructorEventWithNullDependency_Fail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IEventDefinitionRepository eventRepository = new StubIEventDefinitionRepository(); var target = new SessionsController(sessionRepository, null); }
public void CommentsController_ContructorSessionWithNullDependency_Fail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); ICommentRepository commentRepository = new StubICommentRepository(); var target = new CommentsController(commentRepository, null); }
public void MaterialsController_Contructor_NotFail_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository(); var target = new MaterialsController(materialRepository, sessionRepository); }
public void MaterialsController_Contructor_SessionArgumentNullException_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository(); var target = new MaterialsController(materialRepository, null); }
public void GetMaterials_NotFail_Test() { bool called = false; var expected = new Material() { MaterialId = 10 }; ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository() { GetInt32 = materialId => { Assert.AreEqual(expected.MaterialId, materialId); called = true; return expected; } }; var target = new MaterialsController(materialRepository, sessionRepository); Material actual = target.Get(expected.MaterialId); Assert.IsTrue(called); }
public void MaterialsController_Contructor_SessionArgumentNullException_Test() { ISessionRepository sessionRepository = new StubISessionRepository(); IMaterialRepository materialRepository = new StubIMaterialRepository(); var target = new MaterialsController(materialRepository, null); }