Beispiel #1
0
        public void E110_Create()
        {
            AgentTester.PrepareExecutionContext();

            var r = new Robot
            {
                ModelNo     = "T500",
                SerialNo    = "321987",
                EyeColor    = "BLUE",
                PowerSource = "N"
            };

            // Create a robot.
            r = AgentTester.Test <RobotAgent, Robot>()
                .ExpectStatusCode(HttpStatusCode.Created)
                .ExpectChangeLogCreated()
                .ExpectETag()
                .ExpectUniqueKey()
                .ExpectEventWithValue("Demo.Robot.*", "Create")
                .ExpectValue((t) => r)
                .Run(a => a.CreateAsync(r)).Value;

            // Check the robot was created properly.
            AgentTester.Test <RobotAgent, Robot>()
            .ExpectStatusCode(HttpStatusCode.OK)
            .ExpectValue((t) => r)
            .Run(a => a.GetAsync(r.Id));
        }
Beispiel #2
0
        public void E120_Create_Duplicate()
        {
            AgentTester.PrepareExecutionContext();

            var r = new Robot
            {
                ModelNo     = "T500",
                SerialNo    = "123456",
                EyeColor    = "BLUE",
                PowerSource = "N"
            };

            // Try to create a robot which will result in a duplicate.
            AgentTester.TestGrpc <RobotAgent, Robot>()
            .ExpectStatusCode(HttpStatusCode.Conflict)
            .ExpectErrorType(ErrorType.DuplicateError)
            .ExpectNoEvents()
            .Run(a => a.CreateAsync(r));
        }