public async Task World_does_not_add_same_realm_twice() { // Arrange IRealmFactory factory = Mock.Of <IRealmFactory>( mock => mock.CreateRealm(It.IsAny <string>(), It.IsAny <IWorld>()) == Task.FromResult( Mock.Of <IRealm>(r => r.Name == "Unit Test"))); var world = new MudWorld(factory); var realmName = "Test Realm"; IRealm realm = await world.CreateRealm(realmName); // Act await world.AddRealmToWorld(realm); await world.AddRealmToWorld(realm); // Assert Assert.AreEqual(1, world.GetRealmsInWorld().Count()); }
public async Task Adding_realm_to_world_without_a_name_throws_exception() { // Arrange IRealmFactory factory = Mock.Of <IRealmFactory>( mock => mock.CreateRealm(It.IsAny <string>(), It.IsAny <IWorld>()) == Task.FromResult(Mock.Of <IRealm>())); var world = new MudWorld(factory); var realmName = "Test Realm"; IRealm realm = await world.CreateRealm(realmName); // Act await world.AddRealmToWorld(realm); // Assert Assert.Fail(); }
public async Task Adding_realm_sets_its_enabled_flag() { // Arrange IRealmFactory factory = Mock.Of <IRealmFactory>(mock => mock.CreateRealm(It.IsAny <string>(), It.IsAny <IWorld>()) == Task.FromResult( Mock.Of <IRealm>(r => r.Name == "Unit Test" && r.IsEnabled == true))); var world = new MudWorld(factory); var realmName = "Test Realm"; IRealm realm = await world.CreateRealm(realmName); // Act await world.AddRealmToWorld(realm); // Assert Assert.IsTrue(realm.IsEnabled); }