Example #1
0
        public void PostClienteApp1()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json")
                         .Build();
            var repo      = new RepositorioCliente(config);
            var controler = new UpdatesController(repo);
            var eventos   = GetEventsList();
            var result    = controler.PostCliente(eventos);

            Assert.IsType <OkResult>(result);
        }
Example #2
0
        public void AddUpdateTest()
        {
            // Arrange
            var fakeRepo   = new FakeUpdateRepository();
            var controller = new UpdatesController(fakeRepo);
            var update     = new Update()
            {
                UpdateTitle = "Update Title",
                UpdateText  = "UPDATE TEXT"
            };

            // Act
            controller.NewUpdate(update);

            // Assert
            // Ensure that the review was added to the repository
            var retrievedUpdate = fakeRepo.Updates.ToList()[0];

            Assert.Equal(0, System.DateTime.Now.Date.CompareTo(retrievedUpdate.UpdateDate.Date));
        }
Example #3
0
        public UpdatesControllerTests()
        {
            _configMock  = new Mock <IConfiguration>();
            _updatesMock = new Mock <IUpdaterService>();

            _statusModel = new StatusModel()
            {
                FailedResultsQuantity   = 101,
                Finalizing              = true,
                IsUpdatingInProgress    = false,
                IsUpdatingPaused        = true,
                LastCompletedTime       = new DateTime(2000, 01, 02),
                LastError               = "some_error",
                LastStartedTime         = new DateTime(2000, 01, 03),
                LastUpdatedVessel       = "some_vessel",
                MemoryMegabytesUsage    = 152.66F,
                ReurnedVesselsInCurrent = 34623,
                TotalResultsQuantity    = 190300,
                UpdatingDatabase        = true,
                MissingStatuses         = 2,
                MissingSpeeds           = 1,
                MissingLongs            = 0,
                MissingLats             = 3,
                MissingEtas             = 4,
                MissingActivityTimes    = 5,
                MissingAreas            = 6,
                MissingCourses          = 7,
                MissingDestinations     = 8,
                MissingDraughts         = 9
            };

            _configMock.SetupGet(mock => mock[It.Is <string>(s => s == "Authentication:Key")]).Returns("test_security_key");
            _updatesMock.Setup(mock => mock.PauseUpdating()).Returns(true);
            _updatesMock.Setup(mock => mock.StopUpdatingAsync()).ReturnsAsync(true);
            _updatesMock.Setup(mock => mock.GetUpdatingStatus()).Returns(_statusModel);
            _updatesMock.Setup(mock => mock.UpdateSingleVesselAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).ReturnsAsync(true);

            _controller = new UpdatesController(_configMock.Object, _updatesMock.Object);
        }