public ActionResult Subscribe(DateTime startDate, int timeSlace) { if (Session["userName"] == null) { return(RedirectToAction("Login", "Home", null)); } DataLayer dal = new DataLayer(); Schedule sc = new Schedule(); sc.startDate = startDate; sc.userName = Session["userName"].ToString(); sc.endDate = startDate.AddMinutes(timeSlace); dal.Add(sc); Session["Status"] = "Appointment has been created for you!"; return(RedirectToAction("Index")); }
public void TestAdd() { // Arrange var entity = new FakeModel { FirstProperty = "fake4", SecondProperty = 4 }; var index = 0; ReaderMock.Setup(reader => reader.ReadLine()) .Returns(() => file[index++]); ReaderMock.SetupGet(reader => reader.EndOfStream) .Returns(() => index >= file.Length ? true : false); var expectedEntityToCsv = EntityToCSV(file.Count() + 1, entity.FirstProperty, entity.SecondProperty); // Act TestedDataLayer.Add(entity); // Assert WriterMock.Verify(writer => writer.WriteLine(expectedEntityToCsv), Times.Once); }