Пример #1
0
        public void ICanSerializeAndDeserializeARdpUserChangeRequest()
        {
            string         username   = "******";
            string         password   = GetRandomValidPassword();
            DateTimeOffset expiration = DateTimeOffset.UtcNow;
            var            payload    = PayloadConverter.SerializeRdpConnectivityRequest(UserChangeRequestOperationType.Enable, username, password, expiration);

            var converter = new ClusterProvisioningServerPayloadConverter();
            var request   = converter.DeserializeChangeRequest <RdpUserChangeRequest>(payload);

            Assert.AreEqual(username, request.Username, "Round trip serialize/deserialize enable RDP does not match username");
            Assert.AreEqual(password, request.Password, "Round trip serialize/deserialize enable RDP does not match password");
            Assert.AreEqual(expiration, request.ExpirationDate);
            Assert.AreEqual(UserChangeOperationType.Enable, request.Operation, "Round trip serialize/deserialize enable RDP does not match operation requested");

            payload = PayloadConverter.SerializeRdpConnectivityRequest(UserChangeRequestOperationType.Disable, username, password, expiration);

            request = converter.DeserializeChangeRequest <RdpUserChangeRequest>(payload);

            Assert.AreEqual(UserChangeOperationType.Disable, request.Operation, "Round trip serialize/deserialize disabl RDP does not match operation requested");
            // Technically per spec these shouldn't matter for disable... but the serializer should do it's job correctly.
            Assert.AreEqual(username, request.Username, "Round trip serialize/deserialize disable RDP does not match username");
            Assert.AreEqual(password, request.Password, "Round trip serialize/deserialize disable RDP does not match password");
            Assert.AreEqual(expiration, request.ExpirationDate);
        }