Ejemplo n.º 1
0
    public void CreateCommand()
    {
        using var fake = new FakeDbConnection();
        using var conn = new DataConnection(fake, new DataSqlDialect());

        var cmd = conn.CreateCommand();

        assert.NotNull(cmd);
        assert.IsType(typeof(DataCommand), cmd);
    }
Ejemplo n.º 2
0
        public void TestNetworkMessageCanBeSerializedAndDeserialized()
        {
            var kernel = new StandardKernel();

            kernel.Load <ProtogameNetworkModule>();
            kernel.Bind <INetworkMessage>().To <TestNetworkMessage>();

            var serializer = kernel.Get <INetworkMessageSerialization>();
            var message    = new TestNetworkMessage
            {
                TestInteger = 5,
                TestString  = "hello world"
            };
            var  data = serializer.Serialize(message);
            Type messageType;
            var  deserialized = serializer.Deserialize(data, out messageType);

            _assert.Same(messageType, typeof(TestNetworkMessage));
            _assert.NotNull(deserialized);
            _assert.IsType <TestNetworkMessage>(deserialized);

            var content = (TestNetworkMessage)deserialized;

            _assert.Equal(5, content.TestInteger);
            _assert.Equal("hello world", content.TestString);
        }
Ejemplo n.º 3
0
        public void LocalTemplateSchemeResolvesToCorrectProtocol()
        {
            var packageLookup = GetPackageLookup();

            var metadata = packageLookup.Lookup(Environment.CurrentDirectory, new PackageRequestRef("local-template://C:\\Some\\Path", "master", "Windows", true, false));

            _assert.IsType <FolderPackageMetadata>(metadata);

            var folderMetadata = (FolderPackageMetadata)metadata;

            _assert.Equal("C:\\Some\\Path", folderMetadata.Folder);
            _assert.Equal(PackageManager.PACKAGE_TYPE_TEMPLATE, folderMetadata.PackageType);
        }
Ejemplo n.º 4
0
        public void GeneratedFactoryCanSpawn()
        {
            var kernel = CreateKernel();

            var factory = kernel.Get <IGenericFactory <Player, DefaultWorld> >();

            _assert.NotNull(factory);

            var generic = factory.CreateGeneric(null, "hello");

            _assert.NotNull(generic);
            _assert.IsType <DefaultGeneric <Player, string> >(generic);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Verifies that an object is exactly the given type (and not a derived type).
 /// </summary>
 /// <typeparam name="T">The type the object should be</typeparam>
 /// <param name="object">The object to be evaluated</param>
 /// <returns>The object, casted to type T when successful</returns>
 /// <exception cref="IsTypeException">Thrown when the object is not the given type</exception>
 public static T IsType <T>(this IAssert assert, object @object)
 {
     assert.IsType(typeof(T), @object);
     return((T)@object);
 }