Ejemplo n.º 1
0
        public async void TestCreate_InvalidRelationship_ShouldFail()
        {
            // Arrange
            RelationshipsController controller = new RelationshipsController(_context);

            InitializeRelationship();
            relationship.Receiver = 99;

            try
            {
                // Act
                var result = await controller.Create(relationship);

                // Assert
                Assert.IsType <ViewResult>(result);
                ViewResult viewResult = (ViewResult)result;
                Assert.NotNull(viewResult.ViewData.ModelState);
                Assert.NotEmpty(viewResult.ViewData.ModelState.Keys);

                foreach (string item in viewResult.ViewData.ModelState.Keys)
                {
                    Assert.Equal("", item);
                }
            }
            catch (Exception ex)
            {
                Assert.Equal("Microsoft.EntityFrameworkCore.DbUpdateException", ex.GetType().ToString());
            }
        }
Ejemplo n.º 2
0
        public async void TestEdit_InvalidRelationship_ShouldFail()
        {
            // Arrange
            RelationshipsController controller = new RelationshipsController(_context);

            try
            {
                // Act
                Relationship replayRelationship = await _context.Relationship
                                                  .FirstOrDefaultAsync(r => r.Sender == 1 && r.Receiver == 2);

                replayRelationship.Receiver = 99;

                var result = await controller.Edit(replayRelationship.Sender, replayRelationship);

                // Assert
                Assert.IsType <ViewResult>(result);
                ViewResult viewResult = (ViewResult)result;
                Assert.NotNull(viewResult.ViewData.ModelState);
                Assert.NotEmpty(viewResult.ViewData.ModelState.Keys);

                foreach (string item in viewResult.ViewData.ModelState.Keys)
                {
                    Assert.Equal("", item);
                }
            }
            catch (Exception ex)
            {
                Assert.Equal("System.NullReferenceException", ex.GetType().ToString());
            }
        }
Ejemplo n.º 3
0
 public async Task WhenGetRelationshipGetsCalled()
 {
     Setup();
     AuthService.Setup(service => service.AuthorizeSelf(
                           It.IsAny <string>(), It.IsAny <Guid>())).Returns(false);
     _result = await RelationshipsController.GetRelationships(_userId, RelationshipTypeId);
 }
 private void Start()
 {
     eventListController      = FindObjectOfType <EventListController>();
     eventDisplayController   = FindObjectOfType <EventDisplayController>();
     _weatherSignController   = FindObjectOfType <WeatherSignController>();
     _relationshipsController = FindObjectOfType <RelationshipsController>();
     _currencyController      = FindObjectOfType <CurrencyController>();
     _boardEvents             = FindObjectOfType <BoardEvents>();
 }
Ejemplo n.º 5
0
        protected void Setup()
        {
            AuthService             = new Mock <IAuthService>();
            RelationshipsRepository = new Mock <IRelationshipsRepository>();

            RelationshipsController = new RelationshipsController(AuthService.Object, RelationshipsRepository.Object);
            RelationshipsController.ControllerContext             = new ControllerContext();
            RelationshipsController.ControllerContext.HttpContext = new DefaultHttpContext();
            RelationshipsController.ControllerContext.HttpContext.Request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJCb2IgSmVua2lucyIsImp0aSI6IjAzZTE2MGMyLWZhNWItNDg0NS1hMjMwLTU5MDZlZTU1NWY1ZSIsImV4cCI6MTg5MzcwMTYyNywiaXNzIjoibG9jYWxob3N0OjUwMDEiLCJhdWQiOiJsb2NhbGhvc3Q6NTAwMSJ9.C9_Y29A0ky2tObFpp7vyvm3vjlxSU4Tmfj_B1Mvyfh4");
        }
Ejemplo n.º 6
0
            public async Task WhenGetRelationshipsGetsCalled()
            {
                Setup();

                AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true);
                RelationshipsRepository.Setup(repository => repository.GetRelationshipsByIdAndType(
                                                  It.IsAny <Guid>(), It.IsAny <RelationshipType>())).ReturnsAsync(_relationships);

                _result = await RelationshipsController.GetRelationships(_userId, RelationshipTypeId);
            }
Ejemplo n.º 7
0
        public async void TestDelete_InvalidRelationship_ShouldFail()
        {
            // Arrange
            RelationshipsController controller = new RelationshipsController(_context);

            try
            {
                // Act
                var result = await controller.DeleteConfirmed(99);
            }
            // Assert
            catch (Exception ex)
            {
                Assert.Equal("System.ArgumentException", ex.GetType().ToString());
            }
        }
 private void Start()
 {
     relationshipsController = FindObjectOfType <RelationshipsController>();
     _eventGroupList         = JsonUtility.FromJson <EventGroupList>(jsonEventList.text);
 }