Esempio n. 1
0
        public void PutCommandItem_AttributeUpdated_WhenValidObject()
        {
            //Action 4 Test : PUT /api/commands/{Id} : Update Update a single resource, (by Id)
            //Test# 4.1 : Condition = Valid Object Submitted for Update : Result = Attribute is updated

            //Arrange
            var _command = new Command {
                HowTo       = "Do unit test",
                Platform    = "xUNit Platform",
                CommandLine = "dotnet test"
            };

            _dbContext.CommandItems.Add(_command);
            _dbContext.SaveChanges();
            int cmdId = _command.Id;

            _command.HowTo = "dotnet test - updated";

            //Act
            _controller.PutCommandItem(cmdId, _command);
            var result = _dbContext.CommandItems.Find(cmdId);

            //Assert
            Assert.Equal(_command.HowTo, result.HowTo);
        }
Esempio n. 2
0
        public void PutCommandItem_AttributeUpdated()
        {
            // prep
            var commands = CreateCommands(1);

            commands[0].HowTo = "UPDATED";

            // call
            controller.PutCommandItem(commands[0].Id, commands[0]);
            var result = dbContext.CommandItems.Find(commands[0].Id);

            // verify
            Assert.That(commands[0].HowTo == result.HowTo);
        }
Esempio n. 3
0
        public void PutCommandItem_AttributeUpdated_WhenValidObject()
        {
            //Arrange
            var command = new Command {
                HowTo = "Do Somethting", Platform = "Some Platform", CommandLine = "Some Command"
            };

            dbContext.commandItems.Add(command); dbContext.SaveChanges();

            var cmdId = command.Id;

            command.HowTo = "UPDATED";

            //Act
            Controller.PutCommandItem(cmdId, command);
            var result = dbContext.commandItems.Find(cmdId);

            //Assert
            Assert.Equal(command.HowTo, result.HowTo);
        }
Esempio n. 4
0
        public void PutCommandItem_AttributeUpdated_WhenValidObject()
        {
            var command1 = new Command
            {
                HowTo       = "How to 1",
                CommandLine = "command line 1",
                Platform    = "Platform 1"
            };

            controller.PostCommandItem(command1);

            var cmdId = command1.Id;

            command1.HowTo = "Updated how to 1";

            controller.PutCommandItem(cmdId, command1);

            var result = controller.GetCommandItem(cmdId);

            Assert.Equal(command1.HowTo, result.Value.HowTo);
        }
        public void PutCommandItem_AttributeUpdated_WhenUsingValidItem( )
        {
            // Arrange
            var command = new Command
            {
                HowTo       = "Do Something",
                Platform    = "Test 4.1",
                CommandLine = "Some CommandLine"
            };

            _dbContext.CommandItems.Add(command);
            _dbContext.SaveChanges( );

            var cmdId = command.Id;

            command.HowTo = "UPDATED";

            // Act
            _controller.PutCommandItem(cmdId, command);
            var result = _dbContext.CommandItems.Find(cmdId);

            //Assert
            Assert.Equal(command.HowTo, result.HowTo);
        }