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); }
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); }
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); }
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); }
/// <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); }