public async Task AvailabilityController_GetAvailabilityListItemsByIds_AvailabilityListItemsReturned() { var mediator = new Mock <IMediator>(); mediator.Setup(e => e.Send(It.IsAny <GetAvailabilityListItemsByIdsCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <AvailabilityListItemDto> { new AvailabilityListItemDto { Name = "test name", Url = "http://google.com/", Status = "ST_OK" } }); var availabilityController = new AvailabilityController(mediator.Object); var response = await availabilityController .GetAvailabilityListItemsByIds(new List <Guid> { Guid.Empty }, CancellationToken.None) .ConfigureAwait(false); var objectResult = Assert.IsAssignableFrom <OkObjectResult>(response); var recordDtos = (List <AvailabilityListItemDto>)objectResult.Value; Assert.Equal("http://google.com/", recordDtos.First().Url); Assert.Equal("test name", recordDtos.First().Name); Assert.Equal("ST_OK", recordDtos.First().Status); }
public void Setup() { flights = new List <Flight>() { new Flight { FlightId = 1, Company_Name = "Indigo", Starting_Location = "Hyderabad", Destination = "Pune", Available_Seats = 24 }, new Flight { FlightId = 2, Company_Name = "Sahara", Starting_Location = "Pune", Destination = "Bangalore", Available_Seats = 12 } }; flightdata = flights.AsQueryable(); mockSet = new Mock <DbSet <Flight> >(); mockSet.As <IQueryable <Flight> >().Setup(m => m.Provider).Returns(flightdata.Provider); mockSet.As <IQueryable <Flight> >().Setup(m => m.Expression).Returns(flightdata.Expression); mockSet.As <IQueryable <Flight> >().Setup(m => m.ElementType).Returns(flightdata.ElementType); mockSet.As <IQueryable <Flight> >().Setup(m => m.GetEnumerator()).Returns(flightdata.GetEnumerator()); var p = new DbContextOptions <AvailableContext>(); availablecontextmock = new Mock <AvailableContext>(p); availablecontextmock.Setup(x => x.Flights).Returns(mockSet.Object); config = new Mock <IConfiguration>(); config.Setup(p => p["Jwt:Key"]).Returns("ThisismySecretKey"); availablerepo = new AvailabilityRepo(availablecontextmock.Object); mock = new Mock <AvailabilityRepo>(); controller = new AvailabilityController(availablerepo); }
public void TestInitialize() { this.getAvailability = new Mock <IQueryHandler <GetAvailabilityQuery, AvailabilityResult> >(); this.controller = new AvailabilityController(this.getAvailability.Object); this.controller.Request = new HttpRequestMessage(); this.controller.Configuration = new System.Web.Http.HttpConfiguration(); }
public void Reduce_Availability_Success_Test() { mock.Setup(x => x.Reduce(It.IsAny <int>())).Returns(true); var controller = new AvailabilityController(mock.Object); var result = controller.Reduce_Availability(1) as OkResult; Assert.AreEqual(200, result.StatusCode); }
public void Reduce_Availability_Failure_Test() { mock.Setup(x => x.Reduce(It.IsAny <int>())).Returns(false); var controller = new AvailabilityController(mock.Object); var result = controller.Reduce_Availability(1) as StatusCodeResult; Assert.AreEqual(404, result.StatusCode); }
public void Get_Availability_For_Flight_Failure_Test() { mock.Setup(x => x.AvailableCount(It.IsAny <int>())).Returns(null); var controller = new AvailabilityController(mock.Object); var result = controller.Get_Availability_For_Flight(1) as StatusCodeResult; Assert.IsNull(result); }
public void Get_Availability_For_Flight_Success_Test() { mock.Setup(x => x.AvailableCount(It.IsAny <int>())).Returns(It.IsAny <int>()); var controller = new AvailabilityController(mock.Object); var result = controller.Get_Availability_For_Flight(1) as OkObjectResult; Assert.IsNotNull(result); Assert.AreEqual(200, result.StatusCode); }
public void Get_All_Flights_Test() { mock.Setup(x => x.GetFlights()).Returns(flights); var controller = new AvailabilityController(mock.Object); var result = controller.Get_AllFlights() as OkObjectResult; Assert.IsNotNull(result); Assert.AreEqual(200, result.StatusCode); Assert.IsInstanceOf <List <Flight> >(result.Value); }
public void TestInitialize() { _userId = "1"; _userName = "******"; _mockService = new Mock <IUserAvailabilityService>(); _controller = new AvailabilityController(_mockService.Object); _controller.MockHttpContext(_userId, _userName); }
protected override bool DetermineDayMarked(int DayOfMonth, int DayOfWeek) { /*if (ViewState["MarkedState"] != null) * { * ((Boolean[])ViewState["MarkedState"])[DayOfMonth - 1] = TFS.Intranet.Scheduling.AvailabilityHandler.IsAvailable(_username, DayOfMonth, VisibleDate.Month, VisibleDate.Year); * Boolean[] state = (Boolean[])ViewState["MarkedState"]; * return ((Boolean[])ViewState["MarkedState"])[DayOfMonth - 1]; * }*/ return(AvailabilityController.IsAvailable(Username, DayOfMonth, VisibleDate.Month, VisibleDate.Year)); }
public async Task AvailabilityController_DeleteAvailabilityRecord_AvailabilityRecordDeleted() { var mediator = new Mock <IMediator>(); var availabilityController = new AvailabilityController(mediator.Object); var response = await availabilityController .DeleteAvailabilityRecord(Guid.Empty, CancellationToken.None) .ConfigureAwait(false); Assert.IsAssignableFrom <NoContentResult>(response); }
public void TestInitialize() { Mapper.Reset(); Mapper.Initialize(cfg => cfg.AddProfile <MappingProfile>()); _mockService = new Mock <IUserAvailabilityService>(); _controller = new AvailabilityController(_mockService.Object); _userId = "1"; _controller.MockCurrentUser(_userId); }
void HandleDaySelected(object sender, MarkableCalendarSelectedEventArgs args) { if (args.IsMarking) { AvailabilityController.MarkAvailable(Username, args.Day, args.Month, args.Year); } else { AvailabilityController.MarkUnavailable(Username, args.Day, args.Month, args.Year); } this.DataBind(); }
public async Task AvailabilityController_GetAvailabilityRecordById_AvailabilityRecordReturned() { var mediator = new Mock <IMediator>(); mediator.Setup(e => e.Send(It.IsAny <GetAvailabilityRecordByIdCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new AvailabilityRecordDto { Id = Guid.Empty, Name = "test name", Url = "http://google.com/", ExpectedResponse = "{}", ExpectedStatusCode = 200, Status = "ST_OK", LogLifetimeThresholdInHours = 2, AvailabilityLogs = new List <AvailabilityLogDto> { new AvailabilityLogDto { ResponseTime = 25, StatusCode = 200, Body = "{}", CreatedAt = DateTime.MinValue } } }); var availabilityController = new AvailabilityController(mediator.Object); var response = await availabilityController .GetAvailabilityRecordById(Guid.Empty, CancellationToken.None) .ConfigureAwait(false); var objectResult = Assert.IsAssignableFrom <OkObjectResult>(response); var recordDto = (AvailabilityRecordDto)objectResult.Value; Assert.Equal(Guid.Empty, recordDto.Id); Assert.Equal("http://google.com/", recordDto.Url); Assert.Equal("test name", recordDto.Name); Assert.Equal("ST_OK", recordDto.Status); Assert.Equal("{}", recordDto.ExpectedResponse); Assert.Equal(200, recordDto.ExpectedStatusCode); Assert.Equal(2, recordDto.LogLifetimeThresholdInHours); Assert.Single(recordDto.AvailabilityLogs); Assert.Equal(25, recordDto.AvailabilityLogs.First().ResponseTime); Assert.Equal(200, recordDto.AvailabilityLogs.First().StatusCode); Assert.Equal("{}", recordDto.AvailabilityLogs.First().Body); Assert.Equal(DateTime.MinValue, recordDto.AvailabilityLogs.First().CreatedAt); }
public async Task AvailabilityController_CreateAvailabilityRecord_AvailabilityRecordCreated() { var mediator = new Mock <IMediator>(); var availabilityController = new AvailabilityController(mediator.Object); var response = await availabilityController .CreateAvailabilityRecord(new CreateAvailabilityRecordDto { Name = "testName", Url = "http://google.com/", ExpectedResponse = "{}", ExpectedStatusCode = 200, LogLifetimeThresholdInHours = 3 }, CancellationToken.None) .ConfigureAwait(false); Assert.IsAssignableFrom <NoContentResult>(response); }
public void Setup() { // Arrange _availabilityController = new AvailabilityController(); }
private void CargarXML(string query) { string xml = "https://ws.spotify.com/search/1/track.xml?q=" + query; XmlDocument documento = new XmlDocument(); documento.Load(xml); XmlNodeList tracks = documento.GetElementsByTagName("tracks"); foreach (XmlElement nodoTracks in tracks) { XmlNodeList track = nodoTracks.GetElementsByTagName("track"); foreach (XmlElement nodoTrack in track) { XmlNodeList nameTrack = nodoTrack.GetElementsByTagName("name"); XmlNodeList id = nodoTrack.GetElementsByTagName("id"); XmlNodeList trackNumber = nodoTrack.GetElementsByTagName("track-number"); XmlNodeList length = nodoTrack.GetElementsByTagName("length"); XmlNodeList popularity = nodoTrack.GetElementsByTagName("popularity"); t1.Name = nameTrack[0].InnerText; t1.Id = id[0].InnerText; t1.TrackNumber = trackNumber[0].InnerText; t1.Length = Convert.ToDouble(length[0].InnerText); t1.Popularity = Convert.ToDouble(popularity[0].InnerText); TrackController.AgregarTrack(t1); XmlNodeList artist = ((XmlElement)nodoTrack).GetElementsByTagName("artist"); foreach (XmlElement nodoArtist in artist) { XmlNodeList nameArtist = nodoArtist.GetElementsByTagName("name"); a1.Name = nameArtist[0].InnerText; a1.IdTrack = TrackController.ObtenerIdTrack(); ArtistController.AgregarArtist(a1); } XmlNodeList album = ((XmlElement)nodoTrack).GetElementsByTagName("album"); foreach (XmlElement nodoAlbum in album) { XmlNodeList nameAlbum = nodoAlbum.GetElementsByTagName("name"); XmlNodeList released = nodoAlbum.GetElementsByTagName("released"); a2.Name = nameAlbum[0].InnerText; a2.Released = released[0].InnerText; a2.IdTrack = TrackController.ObtenerIdTrack(); AlbumController.AgregarAlbum(a2); XmlNodeList availability = ((XmlElement)nodoAlbum).GetElementsByTagName("availability"); foreach (XmlElement nodoAvailability in availability) { XmlNodeList territories = nodoAvailability.GetElementsByTagName("territories"); a3.Territories = territories[0].InnerText; a3.IdAlbum = AlbumController.ObtenerIdAlbum(); AvailabilityController.AgregarAvailability(a3); } } } } }