TraderHelper. Filter Security uses SecurityMessage overload.

--- Algo/TraderHelper.cs
+++ Algo/TraderHelper.cs
@@ -1842,14 +1842,8 @@
 			if (securities == null)
 				throw new ArgumentNullException(nameof(securities));

-			if (criteria == null)
-				throw new ArgumentNullException(nameof(criteria));
-
 			if (criteria.IsLookupAll())
 				return securities.ToArray();
-
-			//if (!criteria.SecurityId.IsDefault())
-			//	return securities.Where(s => s.Id == criteria.Id).ToArray();

 			return securities.Where(s => s.IsMatch(criteria, criteria.GetSecurityTypes())).ToArray();
 		}
@@ -1876,127 +1870,11 @@
 			if (securities == null)
 				throw new ArgumentNullException(nameof(securities));

-			if (criteria == null)
-				throw new ArgumentNullException(nameof(criteria));
-
 			if (criteria.IsLookupAll())
 				return securities.ToArray();

-			var secId = criteria.SecurityId;
-			var secCode = secId.SecurityCode;
-			var boardCode = secId.BoardCode;
-
-			if (!secCode.IsEmpty() && !boardCode.IsEmpty())
-			{
-				var id = secId.ToStringId();
-				return securities.Where(s => s.Id.CompareIgnoreCase(id)).ToArray();
-			}
-
-			var secTypes = criteria.GetSecurityTypes();
-			var underSecCode = criteria.UnderlyingSecurityCode;
-
-			return securities.Where(s =>
-			{
-				if (!secCode.IsEmpty() && !s.Code.ContainsIgnoreCase(secCode))
-					return false;
-
-				if (!boardCode.IsEmpty())
-				{
-					if (s.Board != null && !s.Board.Code.CompareIgnoreCase(boardCode))
-						return false;
-				}
-
-				if (secTypes.Count > 0)
-				{
-					if (s.Type == null || !secTypes.Contains(s.Type.Value))
-						return false;
-				}
-
-				if (!underSecCode.IsEmpty() && !s.UnderlyingSecurityId.ContainsIgnoreCase(underSecCode))
-					return false;
-
-				if (criteria.Strike != null && s.Strike != criteria.Strike)
-					return false;
-
-				if (criteria.OptionType != null && s.OptionType != criteria.OptionType)
-					return false;
-
-				if (criteria.Currency != null && s.Currency != criteria.Currency)
-					return false;
-
-				if (!criteria.Class.IsEmptyOrWhiteSpace() && !s.Class.ContainsIgnoreCase(criteria.Class))
-					return false;
-
-				if (!criteria.Name.IsEmptyOrWhiteSpace() && !s.Name.ContainsIgnoreCase(criteria.Name))
-					return false;
-
-				if (!criteria.ShortName.IsEmptyOrWhiteSpace() && !s.ShortName.ContainsIgnoreCase(criteria.ShortName))
-					return false;
-
-				if (!criteria.CfiCode.IsEmptyOrWhiteSpace() && !s.CfiCode.ContainsIgnoreCase(criteria.CfiCode))
-					return false;
-
-				if (!secId.Bloomberg.IsEmptyOrWhiteSpace() && !s.ExternalId.Bloomberg.ContainsIgnoreCase(secId.Bloomberg))
-					return false;
-
-				if (!secId.Cusip.IsEmptyOrWhiteSpace() && !s.ExternalId.Cusip.ContainsIgnoreCase(secId.Cusip))
-					return false;
-
-				if (!secId.IQFeed.IsEmptyOrWhiteSpace() && !s.ExternalId.IQFeed.ContainsIgnoreCase(secId.IQFeed))
-					return false;
-
-				if (!secId.Isin.IsEmptyOrWhiteSpace() && !s.ExternalId.Isin.ContainsIgnoreCase(secId.Isin))
-					return false;
-
-				if (!secId.Ric.IsEmptyOrWhiteSpace() && !s.ExternalId.Ric.ContainsIgnoreCase(secId.Ric))
-					return false;
-
-				if (!secId.Sedol.IsEmptyOrWhiteSpace() && !s.ExternalId.Sedol.ContainsIgnoreCase(secId.Sedol))
-					return false;
-
-				if (criteria.ExpiryDate != null && s.ExpiryDate != null && s.ExpiryDate != criteria.ExpiryDate)
-					return false;
-
-				if (criteria.IssueDate != null && s.IssueDate != null && s.IssueDate != criteria.IssueDate)
-					return false;
-
-				if (criteria.IssueSize != null && s.IssueSize != null && s.IssueSize != criteria.IssueSize)
-					return false;
-
-				if (criteria.UnderlyingSecurityType != null && s.UnderlyingSecurityType != null && s.UnderlyingSecurityType != criteria.UnderlyingSecurityType)
-					return false;
-
-				if (criteria.MinVolume != null && s.MinVolume != null && s.MinVolume != criteria.MinVolume)
-					return false;
-
-				if (criteria.MaxVolume != null && s.MaxVolume != null && s.MaxVolume != criteria.MaxVolume)
-					return false;
-
-				if (criteria.UnderlyingSecurityMinVolume != null && s.UnderlyingSecurityMinVolume != null && s.UnderlyingSecurityMinVolume != criteria.UnderlyingSecurityMinVolume)
-					return false;
-
-				if (criteria.Shortable != null && s.Shortable != null && s.Shortable != criteria.Shortable)
-					return false;
-
-				if (criteria.FaceValue != null && s.FaceValue != null && s.FaceValue != criteria.FaceValue)
-					return false;
-
-				if (criteria.ExtensionInfo != null && criteria.ExtensionInfo.Count > 0)
-				{
-					if (s.ExtensionInfo == null)
-						return false;
-
-					foreach (var pair in criteria.ExtensionInfo)
-					{
-						var value = s.ExtensionInfo.TryGetValue(pair.Key);
-
-						if (!pair.Value.Equals(value))
-							return false;
-					}
-				}
-
-				return true;
-			}).ToArray();
+			var dict = securities.ToDictionary(s => s.ToMessage(), s => s);
+			return dict.Keys.Filter(criteria).Select(m => dict[m]).ToArray();
 		}

 		/// <summary>


(ReadIndex): prioritize PRS images detection.

--- ArcFormats/ArcMBL.cs
+++ ArcFormats/ArcMBL.cs
@@ -112,10 +112,9 @@
                     {
                         entry = new AutoEntry (name, () => {
                             uint signature = file.View.ReadUInt32 (offset);
-                            var res = FormatCatalog.Instance.LookupSignature (signature);
-                            if (!res.Any() && 0x4259 == (0xffff & signature))
-                                res = FormatCatalog.Instance.ImageFormats.Where (x => x.Tag == "PRS");
-                            return res.FirstOrDefault();
+                            if (0x4259 == (0xffff & signature))
+                                return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == "PRS");
+                            return FormatCatalog.Instance.LookupSignature (signature).FirstOrDefault();
                         });
                     }
                     entry.Offset = offset;


Simplify params argument now that it is only ever given a single item, the test `assemblyPath`.

--- src/Fixie.TestAdapter/TestAssembly.cs
+++ src/Fixie.TestAdapter/TestAssembly.cs
@@ -40,9 +40,9 @@
             return null;
         }

-        static Process Start(IFrameworkHandle frameworkHandle, string workingDirectory, params string[] arguments)
+        static Process Start(IFrameworkHandle frameworkHandle, string workingDirectory, string assemblyPath)
         {
-            var serializedArguments = CommandLine.Serialize(arguments);
+            var serializedArguments = CommandLine.Serialize(new[] { assemblyPath });

             if (Debugger.IsAttached)
             {


Fix LocalNetwork Node

Fix LocalNetwork Node

When I added refresh, the node for the Local Network was missing the
icon, tag, etc for Scanning.

--- poshsecframework/Interface/frmMain.cs
+++ poshsecframework/Interface/frmMain.cs
@@ -103,7 +103,13 @@
         private void GetNetworks()
         {
             tvwNetworks.Nodes[0].Nodes.Clear();
-            tvwNetworks.Nodes[0].Nodes.Add(new TreeNode("Local Network"));
+            TreeNode lnode = new TreeNode();
+            lnode.Text = "Local Network";
+            lnode.ImageIndex = 3;
+            lnode.SelectedImageIndex = 3;
+            lnode.Tag = 1;
+            tvwNetworks.Nodes[0].Nodes.Add(lnode);
+
             try
             {
                 //Get Domain Name


Fixed minor null reference bug

Fixed minor null reference bug


Amend.

Amend.

--- Gu.Reactive.Tests/Collections/ReadOnlyViews/ReadOnlySerialViewTests.cs
+++ Gu.Reactive.Tests/Collections/ReadOnlyViews/ReadOnlySerialViewTests.cs
@@ -24,7 +24,8 @@
         [Test]
         public void IntializeWithNull()
         {
-            using (var view = new ReadOnlySerialView<int>(null))
+            // ReSharper disable once CollectionNeverUpdated.Local
+            using (var view = new ReadOnlySerialView<int>())
             {
                 CollectionAssert.IsEmpty(view);
             }


HouseholdServiceTests updated with new tests

--- HouseholdManager/HouseholdManager.Logic.Tests/HouseholdServiceTests.cs
+++ HouseholdManager/HouseholdManager.Logic.Tests/HouseholdServiceTests.cs
@@ -13,41 +13,37 @@
     [TestFixture]
     public class HouseholdServiceTests
     {
+        private Mock<IUnitOfWork> unitOfWorkMock;
+        private Mock<IRepository<Household>> householdRepoMock;
+        private Mock<IRepository<User>> userRepoMock;
+        private Mock<IHouseholdFactory> householdFactoryMock;
+
+        [SetUp]
+        public void SetUpMocks()
+        {
+            this.unitOfWorkMock = new Mock<IUnitOfWork>();
+            this.householdRepoMock = new Mock<IRepository<Household>>();
+            this.userRepoMock = new Mock<IRepository<User>>();
+            this.householdFactoryMock = new Mock<IHouseholdFactory>();
+        }
+
         [Test]
         public void HouseholdService_ShouldThrowArgumentNullException_WhenUnitOfWorkIsNull()
         {
-            // Arrange
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-
-            //Act
-            //Assert
+            // Assert
             Assert.Throws<ArgumentNullException>(() => new HouseholdService(null, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object));
         }

         [Test]
         public void HouseholdService_ShouldThrowArgumentNullException_WhenHouseholdRepositoryIsNull()
         {
-            // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-
-            //Act
-            //Assert
+            // Assert
             Assert.Throws<ArgumentNullException>(() => new HouseholdService(unitOfWorkMock.Object, null, userRepoMock.Object, householdFactoryMock.Object));
         }

         [Test]
         public void HouseholdService_ShouldThrowArgumentNullException_WhenUserRepositoryIsNull()
         {
-            // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-
-            //Act
             //Assert
             Assert.Throws<ArgumentNullException>(() => new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, null, householdFactoryMock.Object));
         }
@@ -55,12 +51,6 @@
         [Test]
         public void HouseholdService_ShouldThrowArgumentNullException_WhenHouseholdFactoryIsNull()
         {
-            // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-
-            //Act
             //Assert
             Assert.Throws<ArgumentNullException>(() => new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, null));
         }
@@ -69,179 +59,258 @@
         public void HouseholdFactory_ShouldCallCreateHouseholdOnce_WhenCreateHouseholdIsCalled()
         {
             // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-            var householdStub = new Household("_", "_", new byte[0]);
-            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
-
-            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
-
-            //Act
-            householdService.CreateHousehold("_", "_", new byte[0], "_");
-
-            //Assert
-            householdFactoryMock.Verify(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>()), Times.Once);
+            var householdStub = new Household("_", "_", new byte[0]);
+            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
+
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
+            householdService.CreateHousehold("_", "_", new byte[0], "_");
+
+            // Assert
+            this.householdFactoryMock.Verify(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>()), Times.Once);
         }

         [Test]
         public void UserRepository_ShouldCallGetByIdOnce_WhenCreateHouseholdIsCalled()
         {
             // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-            var householdStub = new Household("_", "_", new byte[0]);
-            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
-
-            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
-
-            //Act
-            householdService.CreateHousehold("_", "_", new byte[0], "_");
-
-            //Assert
-            userRepoMock.Verify(x => x.GetById(It.IsAny<string>()), Times.Once);
+            var householdStub = new Household("_", "_", new byte[0]);
+            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
+
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
+            householdService.CreateHousehold("_", "_", new byte[0], "_");
+
+            // Assert
+            this.userRepoMock.Verify(x => x.GetById(It.IsAny<string>()), Times.Once);
         }

         [Test]
         public void HouseholdRepository_ShouldCallAddOnce_WhenCreateHouseholdIsCalled()
         {
             // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-            var householdStub = new Household("_", "_", new byte[0]);
-            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
-
-            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
-
-            //Act
-            householdService.CreateHousehold("_", "_", new byte[0], "_");
-
-            //Assert
-            householdRepoMock.Verify(x => x.Add(It.IsAny<Household>()), Times.Once);
+            var householdStub = new Household("_", "_", new byte[0]);
+            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
+
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
+            householdService.CreateHousehold("_", "_", new byte[0], "_");
+
+            // Assert
+            this.householdRepoMock.Verify(x => x.Add(It.IsAny<Household>()), Times.Once);
         }

         [Test]
         public void UnitOfWork_ShouldCallCommitOnce_WhenCreateHouseholdIsCalled()
         {
             // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-            var householdStub = new Household("_", "_", new byte[0]);
-            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
-
-            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
-
-            //Act
-            householdService.CreateHousehold("_", "_", new byte[0], "_");
-
-            //Assert
-            unitOfWorkMock.Verify(x => x.Commit(), Times.Once);
+            var householdStub = new Household("_", "_", new byte[0]);
+            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
+
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
+            householdService.CreateHousehold("_", "_", new byte[0], "_");
+
+            // Assert
+            this.unitOfWorkMock.Verify(x => x.Commit(), Times.Once);
         }

         [Test]
         public void HouseholdUsersCount_ShouldBeIncreasedByOne_WhenCreateHouseholdIsCalled()
         {
             // Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
             var householdStub = new Household("_", "_", new byte[0]);
             householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<byte[]>())).Returns(householdStub);
             var expected = householdStub.Users.Count + 1;

             var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);

-            //Act
-            householdService.CreateHousehold("_", "_", new byte[0], "_");
-
-            //Assert
+            // Act
+            householdService.CreateHousehold("_", "_", new byte[0], "_");
+
+            // Assert
             Assert.That(expected == householdStub.Users.Count);
         }

         [Test]
         public void HouseholdRepository_ShouldCallGetFirstOnce_WhenGetHouseholdIsCalled()
         {
-            //Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
-
-            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
-
-            //Act
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
             householdService.GetHousehold(new Guid());

-            //Assert
-            householdRepoMock.Verify(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>()), Times.Once);
+            // Assert
+            this.householdRepoMock.Verify(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>()), Times.Once);
         }

         [Test]
         public void GetHousehold_ShouldReturnInstanceOfHousehold_WhenCalled()
         {
-            //Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
+            // Arrange
             var householdStub = new Household("_", "_", new byte[0]);
             householdRepoMock.Setup(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>())).Returns(householdStub);

             var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);

-            //Act
+            // Act
             var result = householdService.GetHousehold(new Guid());

-            //Assert
+            // Assert
             Assert.IsInstanceOf<Household>(result);
         }

         [Test]
         public void HouseholdRepository_ShouldCallGetFirstOnce_WhenGetHouseholdUsersIsCalled()
         {
-            //Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
+            // Arrange
             var householdStub = new Household("_", "_", new byte[0]);
             householdRepoMock.Setup(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>())).Returns(householdStub);

             var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);

-            //Act
+            // Act
             householdService.GetHouseholdUsers(new Guid());

-            //Assert
-            householdRepoMock.Verify(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>()), Times.Once);
+            // Assert
+            this.householdRepoMock.Verify(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>()), Times.Once);
         }

         [Test]
         public void GetHouseholdUsers_ShouldReturnIEnumerableOfUsers_WhenCalled()
         {
-            //Arrange
-            var unitOfWorkMock = new Mock<IUnitOfWork>();
-            var householdRepoMock = new Mock<IRepository<Household>>();
-            var userRepoMock = new Mock<IRepository<User>>();
-            var householdFactoryMock = new Mock<IHouseholdFactory>();
+            // Arrange
             var householdStub = new Household("_", "_", new byte[0]);
             householdRepoMock.Setup(x => x.GetFirst(It.IsAny<Expression<Func<Household, bool>>>(), It.IsAny<Expression<Func<Household, object>>>())).Returns(householdStub);

             var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);

-            //Act
+            // Act
             var result = householdService.GetHouseholdUsers(new Guid());

-            //Assert
+            // Assert
             Assert.IsInstanceOf<IEnumerable<User>>(result);
+        }
+
+        [Test]
+        public void GetAll_ShouldReturnIEnumerableOfHouseholds_WhenCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
+            var result = householdService.GetAll();
+
+            // Assert
+            Assert.IsInstanceOf<IEnumerable<Household>>(result);
+        }
+
+        [Test]
+        public void HouseholdRepository_ShouldCallGetAllOnce_WhenGetAllIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+
+            // Act
+            householdService.GetAll();
+
+            // Assert
+            this.householdRepoMock.Verify(x => x.GetAll(), Times.Once);
+        }
+
+        [Test]
+        public void HouseholdRepository_ShouldCallGetByIdOnce_WhenUpdateHouseholdInfoIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+            var householdStub = new Household("_", "_", new byte[0]);
+            this.householdRepoMock.Setup(x => x.GetById(It.IsAny<object>())).Returns(householdStub);
+
+            // Act
+            householdService.UpdateHouseholdInfo(new Guid(), "_", "_");
+
+            // Assert
+            this.householdRepoMock.Verify(x => x.GetById(It.IsAny<Guid>()), Times.Once);
+        }
+
+        [Test]
+        public void HouseholdRepository_ShouldCallUpdateOnce_WhenUpdateHouseholdInfoIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+            var householdStub = new Household("_", "_", new byte[0]);
+            this.householdRepoMock.Setup(x => x.GetById(It.IsAny<object>())).Returns(householdStub);
+
+            // Act
+            householdService.UpdateHouseholdInfo(new Guid(), "_", "_");
+
+            // Assert
+            this.householdRepoMock.Verify(x => x.Update(It.IsAny<Household>()), Times.Once);
+        }
+
+        [Test]
+        public void UnotOfWork_ShouldCallCommitOnce_WhenUpdateHouseholdInfoIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+            var householdStub = new Household("_", "_", new byte[0]);
+            this.householdRepoMock.Setup(x => x.GetById(It.IsAny<object>())).Returns(householdStub);
+
+            // Act
+            householdService.UpdateHouseholdInfo(new Guid(), "_", "_");
+
+            // Assert
+            this.unitOfWorkMock.Verify(x => x.Commit(), Times.Once);
+        }
+
+        [Test]
+        public void HouseholdRepository_ShouldCallGetByIdOnce_WhenDeleteIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+            var householdStub = new Household("_", "_", new byte[0]);
+            this.householdRepoMock.Setup(x => x.GetById(It.IsAny<object>())).Returns(householdStub);
+
+            // Act
+            householdService.Delete(new Guid(), true);
+
+            // Assert
+            this.householdRepoMock.Verify(x => x.GetById(It.IsAny<Guid>()), Times.Once);
+        }
+
+        [Test]
+        public void HouseholdRepository_ShouldCallUpdateOnce_WhenDeleteIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+            var householdStub = new Household("_", "_", new byte[0]);
+            this.householdRepoMock.Setup(x => x.GetById(It.IsAny<object>())).Returns(householdStub);
+
+            // Act
+            householdService.Delete(new Guid(), true);
+
+            // Assert
+            this.householdRepoMock.Verify(x => x.Update(It.IsAny<Household>()), Times.Once);
+        }
+
+        [Test]
+        public void UnotOfWork_ShouldCallCommitOnce_WhenDeleteIsCalled()
+        {
+            // Arrange
+            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);
+            var householdStub = new Household("_", "_", new byte[0]);
+            this.householdRepoMock.Setup(x => x.GetById(It.IsAny<object>())).Returns(householdStub);
+
+            // Act
+            householdService.Delete(new Guid(), true);
+
+            // Assert
+            this.unitOfWorkMock.Verify(x => x.Commit(), Times.Once);
         }
     }
 }


Appointment optimization code enum changed

--- SnapMD.VirtualCare.ApiModels/Scheduling/AppointmentOptimizationCode.cs
+++ SnapMD.VirtualCare.ApiModels/Scheduling/AppointmentOptimizationCode.cs
@@ -1,8 +1,18 @@
 namespace SnapMD.VirtualCare.ApiModels.Scheduling
 {
-    public enum AppointmentOptimizationCode : short
+    /// <summary>
+    /// Appointment optimization code.
+    /// </summary>
+    public enum AppointmentOptimizationCode
     {
+        /// <summary>
+        /// Single booking.
+        /// </summary>
         SingleBooking,
+
+        /// <summary>
+        /// Double booking.
+        /// </summary>
         DoubleBooking
     }
 }


River crossing for caulking vehicle will still check for random events.

--- Src/TrailSimulation/Game/Window/Travel/RiverCrossing/CrossingResult.cs
+++ Src/TrailSimulation/Game/Window/Travel/RiverCrossing/CrossingResult.cs
@@ -206,6 +206,11 @@
                     {
                         hasForcedEvent = true;
                         game.EventDirector.TriggerEvent(game.Vehicle, typeof (VehicleFloods));
+                    }
+                    else
+                    {
+                        // Check that we don't flood the user twice, that is just annoying.
+                        game.EventDirector.TriggerEventByType(game.Vehicle, EventCategory.RiverCross);
                     }
                     break;
                 case RiverCrossChoice.Ferry:


Minor refactor

Minor refactor

--- Tests.Unit.Core.ApplicationServices/Infrastructure/DomainEventsTest.cs
+++ Tests.Unit.Core.ApplicationServices/Infrastructure/DomainEventsTest.cs
@@ -7,6 +7,52 @@
 {
     public class DomainEventsTest
     {
+        private const int ExpectedDomainEventId = 1;
+
+        private readonly StandardKernel _kernel;
+
+        public DomainEventsTest()
+        {
+            _kernel = new StandardKernel();
+        }
+
+        [Fact]
+        private void Raise_GivenRegisteredHandler_ThenHandlerIsCalledOnRaisedEvent()
+        {
+            // Arrange
+            var resultHolder = new ResultHolder();
+            _kernel.Bind<IResultHolder>().ToConstant(resultHolder);
+            _kernel.Bind<IDomainEventHandler<MyDomainEvent>>().To<MyHandler>().InThreadScope();
+            var sut = new DomainEvents(_kernel);
+
+            // Act
+            sut.Raise(new MyDomainEvent { Id = ExpectedDomainEventId });
+
+            // Assert
+            Assert.Equal(ExpectedDomainEventId, resultHolder.ResultingValue);
+        }
+
+        [Fact]
+        private void Raise_GivenMultipleRegisteredHandlersOnSameEvent_ThenAllhandlersAreCalledOnRaisedEvent()
+        {
+            // Arrange
+            _kernel.Bind<IResultHolder>().To<ResultHolder>().InThreadScope();
+            var firstHandlerResult = new ResultHolder();
+            var secondHandlerResult = new ResultHolder();
+            _kernel.Bind<IDomainEventHandler<MyDomainEvent>>().ToConstant(new MyHandler(firstHandlerResult)).InThreadScope();
+            _kernel.Bind<IDomainEventHandler<MyDomainEvent>>().ToConstant(new MyHandler(secondHandlerResult)).InThreadScope();
+            var sut = new DomainEvents(_kernel);
+
+            // Act
+            sut.Raise(new MyDomainEvent { Id = ExpectedDomainEventId });
+
+            // Assert
+            Assert.Equal(ExpectedDomainEventId, firstHandlerResult.ResultingValue);
+            Assert.Equal(ExpectedDomainEventId, secondHandlerResult.ResultingValue);
+        }
+
+        #region Helpers
+
         public interface IResultHolder
         {
             int ResultingValue { get; set; }
@@ -37,43 +83,6 @@
             }
         }

-        [Fact]
-        private void Raise_GivenRegisteredDomainEvent_ThenHandlerIsCalled()
-        {
-            // Arrange
-            var kernel = new StandardKernel();
-            var resultHolder = new ResultHolder();
-            kernel.Bind<IResultHolder>().ToConstant(resultHolder);
-            kernel.Bind<IDomainEventHandler<MyDomainEvent>>().To<MyHandler>().InThreadScope();
-            var sut = new DomainEvents(kernel);
-
-            // Act
-            const int expectedDomainEventId = 1;
-            sut.Raise(new MyDomainEvent { Id = expectedDomainEventId });
-
-            // Assert
-            Assert.Equal(expectedDomainEventId, resultHolder.ResultingValue);
-        }
-
-        [Fact]
-        private void Raise_GivenMultipleRegisteredHandlersOnSameEvent_ThenAllhandlersAreCalled()
-        {
-            // Arrange
-            var kernel = new StandardKernel();
-            kernel.Bind<IResultHolder>().To<ResultHolder>().InThreadScope();
-            var firstHandlerResult = new ResultHolder();
-            var secondHandlerResult = new ResultHolder();
-            kernel.Bind<IDomainEventHandler<MyDomainEvent>>().ToConstant(new MyHandler(firstHandlerResult)).InThreadScope();
-            kernel.Bind<IDomainEventHandler<MyDomainEvent>>().ToConstant(new MyHandler(secondHandlerResult)).InThreadScope();
-            var sut = new DomainEvents(kernel);
-
-            // Act
-            const int expectedDomainEventId = 1;
-            sut.Raise(new MyDomainEvent { Id = expectedDomainEventId });
-
-            // Assert
-            Assert.Equal(expectedDomainEventId, firstHandlerResult.ResultingValue);
-            Assert.Equal(expectedDomainEventId, secondHandlerResult.ResultingValue);
-        }
+        #endregion
     }
 }


Role dispatchers have a 24 hour timeout

Role dispatchers have a 24 hour timeout

--- Echo.Process/Role.cs
+++ Echo.Process/Role.cs
@@ -189,8 +189,13 @@
         public static IEnumerable<ProcessId> NodeIds(ProcessId leaf) =>
             Nodes(leaf).Values.Map(node => ProcessId.Top[node.NodeName].Append(leaf.Skip(1)));

-        public static HashMap<ProcessName, ClusterNode> Nodes(ProcessId leaf, SystemName system = default(SystemName)) =>
-            ClusterNodes24(system).Filter(node => node.Role == leaf.Take(1).Name);
+        public static HashMap<ProcessName, ClusterNode> Nodes(ProcessId leaf, SystemName system = default(SystemName))
+        {
+            var nodes = ClusterNodes(system).Filter(node => node.Role == leaf.Take(1).Name);
+            return nodes.Count == 0
+                   ? ClusterNodes24(system).Filter(node => node.Role == leaf.Take(1).Name)
+                   : nodes;
+        }

         static readonly ProcessId nextRoot;
         static readonly ProcessId prevRoot;


Refactored stuff from the constructor to private helpers

--- Elmah.Io/ErrorLog.cs
+++ Elmah.Io/ErrorLog.cs
@@ -36,7 +36,7 @@
         /// </summary>
         public ErrorLog(IDictionary config, IWebClient webClient)
         {
-            if (config == null)
+            if (config == null)
             {
                 throw new ArgumentNullException("config");
             }
@@ -46,44 +46,8 @@
                 throw new ApplicationException("Missing LogId or LogIdKey. Please specify a LogId in your web.config like this: <errorLog type=\"Elmah.Io.ErrorLog, Elmah.Io\" LogId=\"98895825-2516-43DE-B514-FFB39EA89A65\" /> or using AppSettings: <errorLog type=\"Elmah.Io.ErrorLog, Elmah.Io\" LogIdKey=\"MyAppSettingsKey\" /> where MyAppSettingsKey points to a AppSettings with the key 'MyAPpSettingsKey' and value equal LogId.");
             }

-            if (config.Contains("LogId"))
-            {
-                Guid result;
-                if (!Guid.TryParse(config["LogId"].ToString(), out result))
-                {
-                    throw new ApplicationException("Invalid LogId. Please specify a valid LogId in your web.config like this: <errorLog type=\"Elmah.Io.ErrorLog, Elmah.Io\" LogId=\"98895825-2516-43DE-B514-FFB39EA89A65\" />");
-                }
-
-                _logId = result.ToString();
-            }
-            else
-            {
-                var appSettingsKey = config["LogIdKey"].ToString();
-                var value = ConfigurationManager.AppSettings.Get(appSettingsKey);
-                if (value == null)
-                {
-                    throw new ApplicationException("You are trying to reference a AppSetting which is not found (key = '" + appSettingsKey + "'");
-                }
-
-                Guid result;
-                if (!Guid.TryParse(value, out result))
-                {
-                    throw new ApplicationException("Invalid LogId. Please specify a valid LogId in your web.config like this: <appSettings><add key=\"" + appSettingsKey + "\" value=\"98895825-2516-43DE-B514-FFB39EA89A65\" />");
-                }
-
-                _logId = result.ToString();
-            }
-
-            if (config.Contains("Url"))
-            {
-                Uri uri;
-                if (!Uri.TryCreate(config["Url"].ToString(), UriKind.Absolute, out uri))
-                {
-                    throw new ApplicationException("Invalid URL. Please specify a valid absolute url. In fact you don't even need to specify an url, which will make the error logger use the elmah.io backend.");
-                }
-
-                _url = new Uri(config["Url"].ToString());
-            }
+            _logId = ResolveLogId(config);
+            _url = ResolveUrl(config);

             _webClient = webClient;
         }
@@ -185,12 +149,72 @@
             return new Uri(_url, "api/errors" + q.ToQueryString());
         }

-        static T EndImpl<T>(IAsyncResult asyncResult)
-        {
-            if (asyncResult == null) throw new ArgumentNullException("asyncResult");
+        private T EndImpl<T>(IAsyncResult asyncResult)
+        {
+            if (asyncResult == null)
+            {
+                throw new ArgumentNullException("asyncResult");
+            }
+
             var task = asyncResult as Task<T>;
-            if (task == null) throw new ArgumentException(null, "asyncResult");
+            if (task == null)
+            {
+                throw new ArgumentException(null, "asyncResult");
+            }
+
             return task.Result;
+        }
+
+        private Uri ResolveUrl(IDictionary config)
+        {
+            if (!config.Contains("Url"))
+            {
+                return _url;
+            }
+
+            Uri uri;
+            if (!Uri.TryCreate(config["Url"].ToString(), UriKind.Absolute, out uri))
+            {
+                throw new ApplicationException(
+                    "Invalid URL. Please specify a valid absolute url. In fact you don't even need to specify an url, which will make the error logger use the elmah.io backend.");
+            }
+
+            return new Uri(config["Url"].ToString());
+        }
+
+        private string ResolveLogId(IDictionary config)
+        {
+            if (config.Contains("LogId"))
+            {
+                Guid result;
+                if (!Guid.TryParse(config["LogId"].ToString(), out result))
+                {
+                    throw new ApplicationException(
+                        "Invalid LogId. Please specify a valid LogId in your web.config like this: <errorLog type=\"Elmah.Io.ErrorLog, Elmah.Io\" LogId=\"98895825-2516-43DE-B514-FFB39EA89A65\" />");
+                }
+
+                return result.ToString();
+            }
+            else
+            {
+                var appSettingsKey = config["LogIdKey"].ToString();
+                var value = ConfigurationManager.AppSettings.Get(appSettingsKey);
+                if (value == null)
+                {
+                    throw new ApplicationException(
+                        "You are trying to reference a AppSetting which is not found (key = '" + appSettingsKey + "'");
+                }
+
+                Guid result;
+                if (!Guid.TryParse(value, out result))
+                {
+                    throw new ApplicationException(
+                        "Invalid LogId. Please specify a valid LogId in your web.config like this: <appSettings><add key=\""
+                        + appSettingsKey + "\" value=\"98895825-2516-43DE-B514-FFB39EA89A65\" />");
+                }
+
+                return result.ToString();
+            }
         }
     }
 }


Use absolute URL in timeline RSS feed image link.

git-svn-id: 0d96b0c1a6983ccc08b3732614f4d6bfcf9cbb42@1238 af82e41b-90c4-0310-8c96-b1721e28e2e2

--- templates/timeline_rss.cs
+++ templates/timeline_rss.cs
@@ -36,7 +36,7 @@
    <title><?cs var:project.name.encoded ?></title>
    <url><?cs if:!header_logo.src_abs ?><?cs var:base_url ?><?cs /if ?><?cs
     var:header_logo.src ?></url>
-   <link><?cs var:trac.href.timeline ?></link>
+   <link><?cs var:base_url ?><?cs var:trac.href.timeline ?></link>
   </image><?cs
   each:item = timeline.items ?><?cs
    if:item.type == 'changeset' ?><?cs


arranged the starting of the TCP and application more sensibly;

--- examples/TCP/Echo.cs
+++ examples/TCP/Echo.cs
@@ -132,30 +132,29 @@
     this.port = port;
     this.max_conn = max_conn;
     this.max_backlog = max_backlog;
-
-    // Instantiate the TCP implementation
-    tcp = new TCPuny (max_conn, max_backlog, ip_address, mac_address);
-
-    // FIXME factor out, since same code appears in NonPax_Echo_Server
-    Console.WriteLine("Starting Echo server at " + ip_address.ToString() + ":" + port.ToString());
-    Console.WriteLine("Max. connections " + max_conn.ToString() + ", max. backlog " + max_backlog.ToString());
-
-    server = new Echo_Server(tcp, port, ip_address, verbose);
   }

   public void PreStart (ICaptureDevice device) {
+    Console.WriteLine("Instantiating TCP");
+    Console.WriteLine("Max. connections " + max_conn.ToString() + ", max. backlog " + max_backlog.ToString());
+    // Instantiate the TCP implementation
+    tcp = new TCPuny (max_conn, max_backlog, ip_address, mac_address);
     tcp.PreStart(device);
   }

   public void Start () {
+    Console.WriteLine("Starting TCP");
     Thread t = new Thread (new ThreadStart (tcp.Start));
     t.Start();

+    Console.WriteLine("Starting Echo server at " + ip_address.ToString() + ":" + port.ToString());
+    server = new Echo_Server(tcp, port, ip_address, verbose);
     server.start();
   }

   public void Stop () {
     tcp.Stop();
+    Console.WriteLine("Stopped TCP");
   }

   public void packetHandler (object sender, CaptureEventArgs e) {


Do not lookup Java SDK path on global Cake scope.

Fixes https://github.com/mono/Embeddinator-4000/issues/564.

--- build/Tests.cake
+++ build/Tests.cake
@@ -191,8 +191,6 @@
     return javaHome;
 }

-string javaHome = GetJavaSdkPath();
-
 var classPath = string.Join(IsRunningOnWindows() ? ";" : ":", new[]
 {
     "./external/junit/hamcrest-core-1.3.jar",
@@ -207,7 +205,7 @@
     {
         var output = mkDir + Directory("java");
         var tests = File("./tests/common/java/mono/embeddinator/Tests.java");
-        var javac = IsRunningOnLinux() ? "javac" : Directory(javaHome) + File("bin/javac");
+        var javac = IsRunningOnLinux() ? "javac" : Directory(GetJavaSdkPath()) + File("bin/javac");
         Exec(javac, $"-cp {classPath} -d {output} -Xdiags:verbose -Xlint:deprecation -Xlint:unchecked {tests}");
     });

@@ -215,7 +213,7 @@
     .IsDependentOn("Build-Java-Tests")
     .Does(() =>
     {
-        var java = IsRunningOnLinux() ? "java" : Directory(javaHome) + File("bin/java");
+        var java = IsRunningOnLinux() ? "java" : Directory(GetJavaSdkPath()) + File("bin/java");
         Exec(java, $"-cp {classPath} -Djna.dump_memory=true -Djna.nosys=true org.junit.runner.JUnitCore mono.embeddinator.Tests");
     });


modify build.cake

--- build/build.cake
+++ build/build.cake
@@ -165,10 +165,9 @@
             }
             catch{}

-            // RestorePackages, otherwise it fails on VSTS.
             // Build.
             MSBuild(projectPath, new MSBuildSettings() { ToolPath= msBuildPath}
-                .WithTarget("restore;build")
+                .WithTarget("build")
                 .SetConfiguration(configuration)
                 .SetVerbosity(Verbosity.Minimal)
                 .SetNodeReuse(false));


Fix cake build file :/

Fix cake build file :/

--- build/build.cake
+++ build/build.cake
@@ -42,7 +42,7 @@
     Information("Running under AppVeyor");
     var version = System.IO.File.ReadAllText(paths.version);
     var gitVersion = GitVersion();
-    var version += "-" + gitVersion.Sha;
+    version += "-" + gitVersion.Sha;
     Information("Updating AppVeyor build version to " + version);
     AppVeyor.UpdateBuildVersion(version);
 });


Removed redundant comments from build script.

--- build/build.cake
+++ build/build.cake
@@ -68,9 +68,6 @@
             throw new Exception("Unit test failure for test project " + testPath);
         }
     }
-    //DotnetCoreTest();
-	// TODO: Use dotnet CLI tools
-    // XUnit2("../src/**/bin/" + configuration + "/*.Tests.dll");
 });

 Task("Package")


Reflection: Fix DefaultValue exception with enums (#17917)

This is related to dbcfd2f9d1, but about enums instead of `DateTime`.

Given e.g. a generic method with a parameter `T arg = default(T)`
where `T` is the generic type parameter, if that is instantiated with
some enum as the generic type argument, then querying the default
value of `arg` using `ParameterInfo.[Raw]DefaultValue` will throw a
`FormatException`.

(The use of generics means that the C# compiler always records a
`null` constant in metadata, which isn't usually the case for enums.)

--- src/mscorlib/src/System/Reflection/MdConstant.cs
+++ src/mscorlib/src/System/Reflection/MdConstant.cs
@@ -67,6 +67,9 @@
                     case CorElementType.U8:
                         defaultValue = buffer;
                         break;
+
+                    case CorElementType.Class:
+                        return null;

                     default:
                         throw new FormatException(SR.Arg_BadLiteralFormat);


Version change.

Version change.


xmldoc

xmldoc


Minor fix

Minor fix


fix background music loop

fix background music loop


Corrected the Mac detection logic

Corrected the Mac detection logic

--- cake/UtilsManaged.cake
+++ cake/UtilsManaged.cake
@@ -1,3 +1,4 @@
+using System.Runtime.InteropServices;

 var RunNuGetRestore = new Action<FilePath> ((solution) =>
 {
@@ -82,8 +83,35 @@
     }
 });

+internal static class MacPlatformDetector
+{
+    internal static readonly Lazy<bool> IsMac = new Lazy<bool> (IsRunningOnMac);
+
+    [DllImport ("libc")]
+    static extern int uname (IntPtr buf);
+
+    static bool IsRunningOnMac ()
+    {
+        IntPtr buf = IntPtr.Zero;
+        try {
+            buf = Marshal.AllocHGlobal (8192);
+            // This is a hacktastic way of getting sysname from uname ()
+            if (uname (buf) == 0) {
+                string os = Marshal.PtrToStringAnsi (buf);
+                if (os == "Darwin")
+                    return true;
+            }
+        } catch {
+        } finally {
+            if (buf != IntPtr.Zero)
+                Marshal.FreeHGlobal (buf);
+        }
+        return false;
+    }
+}
+
 var IsRunningOnMac = new Func<bool> (() => {
-    return System.Environment.OSVersion.Platform == PlatformID.MacOSX;
+    return System.Environment.OSVersion.Platform == PlatformID.MacOSX || MacPlatformDetector.IsMac.Value;
 });

 var IsRunningOnLinux = new Func<bool> (() => {


制空値計算式を更新

制空値計算式を更新

--- source/Grabacr07.KanColleWrapper/Calculator.cs
+++ source/Grabacr07.KanColleWrapper/Calculator.cs
@@ -8,47 +8,7 @@
 {
 	internal static class Calculator
 	{
-		/// <summary>
-		/// 熟練度による制空能力ボーナス最小値を計算します。
-		/// </summary>
-		/// <param name="slotItem">対空能力を持つ装備。</param>
-		/// <param name="onslot">搭載数。</param>
-		/// <returns></returns>
-		public static int CalcMinAdeptBonusAirSuperiorityPotential(this SlotItem slotItem, int onslot)
-			=> onslot < 1 ? 0
-			: slotItem.Info.Type == SlotItemType.艦上戦闘機
-				? slotItem.Adept == 1 ? 1
-				: slotItem.Adept == 2 ? 4
-				: slotItem.Adept == 3 ? 6
-				: slotItem.Adept == 4 ? 11
-				: slotItem.Adept == 5 ? 16
-				: slotItem.Adept == 6 ? 17
-				: slotItem.Adept == 7 ? 25
-				: 0 // Adept == 0
-			: 0;	// 艦戦以外は簡単に吹き飛ぶので最小値としては計算に入れない
-
-		/// <summary>
-		/// 熟練度による制空能力ボーナス最大値を計算します。
-		/// </summary>
-		/// <param name="slotItem">対空能力を持つ装備。</param>
-		/// <param name="onslot">搭載数。</param>
-		/// <returns></returns>
-		public static int CalcMaxAdeptBonusAirSuperiorityPotential(this SlotItem slotItem, int onslot)
-			=> onslot < 1 ? 0
-			: slotItem.Info.Type == SlotItemType.艦上戦闘機
-				? slotItem.Adept == 1 ? 2
-				: slotItem.Adept == 2 ? 5
-				: slotItem.Adept == 3 ? 8
-				: slotItem.Adept == 4 ? 12
-				: slotItem.Adept == 5 ? 18
-				: slotItem.Adept == 6 ? 18
-				: slotItem.Adept == 7 ? 26
-				: 1 // Adept == 0
-			// 艦戦以外はよくわからないので暫定的に1次関数＆切り上げ
-			: slotItem.Info.Type == SlotItemType.艦上攻撃機 ? (int)Math.Ceiling(3 * slotItem.Adept / 7d)
-			: slotItem.Info.Type == SlotItemType.艦上爆撃機 ? (int)Math.Ceiling(3 * slotItem.Adept / 7d)
-			: slotItem.Info.Type == SlotItemType.水上爆撃機 ? (int)Math.Ceiling(9 * slotItem.Adept / 7d)
-			: 0;
+		#region 制空値計算

 		/// <summary>
 		/// 装備と搭載数を指定して、スロット単位の制空能力を計算します。
@@ -82,7 +42,7 @@
 		{
 			return ship.EquippedItems
 				.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)
-							+ x.Item.CalcMinAdeptBonusAirSuperiorityPotential(x.Current))
+							+ x.Item.CalcMinAirecraftAdeptBonus(x.Current))
 				.Sum();
 		}

@@ -93,9 +53,74 @@
 		{
 			return ship.EquippedItems
 				.Select(x => x.Item.CalcAirSuperiorityPotential(x.Current)
-							+ x.Item.CalcMaxAdeptBonusAirSuperiorityPotential(x.Current))
+							+ x.Item.CalcMaxAirecraftAdeptBonus(x.Current))
 				.Sum();
 		}
+		/// <summary>
+		/// 熟練度による制空能力ボーナス最小値を計算します。
+		/// </summary>
+		/// <param name="slotItem">対空能力を持つ装備。</param>
+		/// <param name="onslot">搭載数。</param>
+		/// <returns></returns>
+		private static int CalcMinAirecraftAdeptBonus(this SlotItem slotItem, int onslot)
+			=> onslot < 1 ? 0
+			: slotItem.Info.Type == SlotItemType.艦上戦闘機
+				? slotItem.CalcAirecraftAdeptBonusOfType() + slotItem.CalcMinInternalAirecraftAdeptBonus()
+				: 0;    // 艦戦以外は簡単に吹き飛ぶので最小値としては計算に入れない
+
+		/// <summary>
+		/// 熟練度による制空能力ボーナス最大値を計算します。
+		/// </summary>
+		/// <param name="slotItem">対空能力を持つ装備。</param>
+		/// <param name="onslot">搭載数。</param>
+		/// <returns></returns>
+		private static int CalcMaxAirecraftAdeptBonus(this SlotItem slotItem, int onslot)
+			=> onslot < 1 ? 0
+			: slotItem.CalcAirecraftAdeptBonusOfType() + slotItem.CalcMaxInternalAirecraftAdeptBonus();
+
+		/// <summary>
+		/// 各表記熟練度に対応した機種別熟練度ボーナスを計算します。
+		/// </summary>
+		/// <param name="slotItem"></param>
+		/// <returns></returns>
+		private static int CalcAirecraftAdeptBonusOfType(this SlotItem slotItem)
+			=> slotItem.Info.Type == SlotItemType.艦上戦闘機
+				? slotItem.Adept == 1 ? 0
+				: slotItem.Adept == 2 ? 2
+				: slotItem.Adept == 3 ? 5
+				: slotItem.Adept == 4 ? 9
+				: slotItem.Adept == 5 ? 14
+				: slotItem.Adept == 6 ? 14
+				: slotItem.Adept == 7 ? 22
+				: 0 // Adept == 0
+			: slotItem.Info.Type == SlotItemType.水上爆撃機
+				? slotItem.Adept == 1 ? 0
+				: slotItem.Adept == 2 ? 1
+				: slotItem.Adept == 3 ? 1
+				: slotItem.Adept == 4 ? 1
+				: slotItem.Adept == 5 ? 3
+				: slotItem.Adept == 6 ? 3
+				: slotItem.Adept == 7 ? 6
+				: 0 // Adept == 0
+			: 0;
+
+		/// <summary>
+		/// 各表記熟練度に対応した艦載機内部熟練度ボーナスの最小値を計算します。
+		/// </summary>
+		/// <param name="slotItem"></param>
+		/// <returns></returns>
+		private static int CalcMinInternalAirecraftAdeptBonus(this SlotItem slotItem)
+			=> (int)Math.Sqrt((slotItem.Adept != 0 ? (slotItem.Adept - 1) * 15 + 10 : 0) / 10);
+
+		/// <summary>
+		/// 各表記熟練度に対応した艦載機内部熟練度ボーナスの最大値を計算します。
+		/// </summary>
+		/// <param name="slotItem"></param>
+		/// <returns></returns>
+		private static int CalcMaxInternalAirecraftAdeptBonus(this SlotItem slotItem)
+			=> (int)Math.Sqrt((slotItem.Adept != 0 ? (slotItem.Adept - 1) * 15 + 24 : 9) / 10);
+
+		#endregion

 		public static double CalcViewRange(this Fleet fleet)
 		{


Update TransactionParse.cs

Update TransactionParse.cs

--- source/Uol.PagSeguro/Parse/TransactionParse.cs
+++ source/Uol.PagSeguro/Parse/TransactionParse.cs
@@ -198,13 +198,13 @@
                     if (PagSeguroUtil.IsEmpty(item.Key) || PagSeguroUtil.IsEmpty(item.Value))
                         continue;

-                    if (item.Group)
-                        data[item.Key + "" + item.Group] = item.Value;
-                    else
-                        data[item.Key] = item.Value;
-                }
-            }
-
+                    {   if (item.Group)
+                            data[item.Key + "" + item.Group] = item.Value;
+                        else
+                            data[item.Key] = item.Value;
+                    }
+                }
+            }
             switch (checkout)
             {
                 //Verify if exists the credit card checkout data


I hate #if directive...

I hate #if directive...

--- source/VirtualDesktop/VirtualDesktop.static.cs
+++ source/VirtualDesktop/VirtualDesktop.static.cs
@@ -20,7 +20,7 @@
 #if DEBUG
 			_isSupportedInternal;
 #else
-			Environment.OSVersion.Version.Major >= 10 && isSupportedInternal;
+			Environment.OSVersion.Version.Major >= 10 && _isSupportedInternal;
 #endif

 		[EditorBrowsable(EditorBrowsableState.Never)]


Added UnicodeUtils::GetCodePointInfo(string,int,out int):UnicodeCategory method

--- cs/src/pegleg.cs/Utils/UnicodeUtils.cs
+++ cs/src/pegleg.cs/Utils/UnicodeUtils.cs
@@ -28,7 +28,7 @@

 		/// <summary>
 		/// <para>
-		/// Retrieve the <see cref="UnicodeCategory"/> and length of the UTF-16 grapheme at the specified
+		/// Retrieve the <see cref="UnicodeCategory"/> and <paramref name="length"/> of the UTF-16 grapheme at the specified
 		/// <paramref name="index"/> in <paramref name="str"/>.
 		/// </para>
 		/// <para>
@@ -81,6 +81,19 @@
 			return category;
 		}

+		/// <summary>
+		/// Retrieve the <see cref="UnicodeCategory"/> and <paramref name="length"/> of the UTF-16 code point at the specified
+		/// <paramref name="index"/> in <paramref name="str"/>.
+		/// </summary>
+		/// <param name="str">The <see cref="string"/> from which code point information should be retrieved.</param>
+		/// <param name="index">The start position in <paramref name="str"/> from which code point information should be retrieved.</param>
+		/// <param name="length">The length of the code point starting at <paramref name="index"/> in <paramref name="str"/>.</param>
+		public static UnicodeCategory GetCodePointInfo(string str, int index, out int length) {
+			if(null == str) throw Xception.Because.ArgumentNull(() => str);
+
+			return CharUnicodeInfo_InternalGetUnicodeCategory(str, index, out length);
+		}
+
 		private static bool IsCombiningCategory(UnicodeCategory uc) {
 			return UnicodeCategory.NonSpacingMark == uc
 				|| UnicodeCategory.SpacingCombiningMark == uc


Views: SwitchTo is public now for using from Unity events system.

--- sources/Assets/Scripts/Utils/Views/ViewBase.cs
+++ sources/Assets/Scripts/Utils/Views/ViewBase.cs
@@ -33,7 +33,7 @@
                 OnHideEvent(this);
         }

-        protected void SwitchTo(ViewBase otherView)
+        public void SwitchTo(ViewBase otherView)
         {
             Hide();
             otherView.Show();


Added test method to check #65 issue fix

--- sources/Test/OpenMcdf.Test/CompoundFileTest.cs
+++ sources/Test/OpenMcdf.Test/CompoundFileTest.cs
@@ -1082,6 +1082,26 @@
         }

         [TestMethod]
+        public void Test_WRONG_CORRUPTED_EXCEPTION()
+        {
+            var cf = new CompoundFile();
+
+            for (int i = 0; i < 100; i++)
+            {
+                cf.RootStorage.AddStream("Stream" + i).SetData(Helpers.GetBuffer(100000, 0xAA));
+            }
+
+            cf.RootStorage.AddStream("BigStream").SetData(Helpers.GetBuffer(5250000, 0xAA));
+
+            using (var stream = new MemoryStream())
+            {
+                cf.Save(stream);
+            }
+
+            cf.Close();
+        }
+
+        [TestMethod]
         [ExpectedException(typeof(CFCorruptedFileException))]
         public void Test_CorruptedSectorChain_Doc2()
         {


if a destination was passed, map to destination subobjects by default, no UseDestinationValue necessary

--- src/AutoMapper/Execution/TypeMapPlanBuilder.cs
+++ src/AutoMapper/Execution/TypeMapPlanBuilder.cs
@@ -284,9 +284,22 @@
                 getter = destMember;
             }

-            var destValueExpr = propertyMap.UseDestinationValue
-                ? getter
-                : Default(propertyMap.DestinationPropertyType);
+            Expression destValueExpr;
+            if(propertyMap.UseDestinationValue)
+            {
+                destValueExpr = getter;
+            }
+            else
+            {
+                if(_initialDestination.Type.IsValueType())
+                {
+                    destValueExpr = Default(propertyMap.DestinationPropertyType);
+                }
+                else
+                {
+                    destValueExpr = Condition(Equal(_initialDestination, Constant(null)), Default(propertyMap.DestinationPropertyType), getter);
+                }
+            }

             var valueResolverExpr = BuildValueResolverFunc(propertyMap, getter);


cosmetic

cosmetic

--- src/AutoMapper/Execution/TypeMapPlanBuilder.cs
+++ src/AutoMapper/Execution/TypeMapPlanBuilder.cs
@@ -525,7 +525,6 @@

         private Expression GetMemberResolver(Expression destValueExpr, Type destinationPropertyType, Expression ctor, Type resolverType, Expression sourceMember)
         {
-            Expression valueResolverFunc;
             var iResolverType = resolverType.GetGenericInterface(typeof(IMemberValueResolver<,,,>));

             var sourceResolverParam = iResolverType.GetGenericArguments()[0];
@@ -533,7 +532,7 @@
             var sourceMemberResolverParam = iResolverType.GetGenericArguments()[2];
             var destMemberResolverParam = iResolverType.GetGenericArguments()[3];

-            valueResolverFunc =
+            return
                 ToType(Call(ToType(ctor, resolverType), resolverType.GetDeclaredMethod("Resolve"),
                     ToType(_source, sourceResolverParam),
                     ToType(_destination, destResolverParam),
@@ -541,7 +540,6 @@
                     ToType(destValueExpr, destMemberResolverParam),
                     _context),
                     destinationPropertyType);
-            return valueResolverFunc;
         }

         public Expression MapExpression(TypePair typePair, Expression sourceParameter, PropertyMap propertyMap = null, Expression destinationParameter = null)


Update Buildbox.SemVer.csproj version to 0.1.103

--- src/Buildbox.SemVer/Properties/AssemblyInfo.cs
+++ src/Buildbox.SemVer/Properties/AssemblyInfo.cs
@@ -64,9 +64,23 @@

 // [assembly: AssemblyVersion("1.0.*")]

-[assembly: AssemblyVersion("0.1.92")]
+[assembly: AssemblyVersion("0.1.103")]

-[assembly: AssemblyFileVersion("0.1.92")]
+[assembly: AssemblyFileVersion("0.1.103")]
+
+
+
+
+
+
+
+
+
+
+
+
+
+


Add controller to validate and register entrance/exit.

--- A2BBAPI/Controllers/InOutController.cs
+++ A2BBAPI/Controllers/InOutController.cs
@@ -1,23 +1,48 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
 using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Authorization;
 using A2BBCommon.Models;
 using A2BBCommon;
 using A2BBAPI.Data;
-using IdentityModel.Client;
-using A2BBAPI.DTO;
 using Microsoft.Extensions.Logging;
+using Microsoft.AspNetCore.Authorization;
+using A2BBAPI.Utils;
+using System.Linq;
+using A2BBAPI.Models;
+using static A2BBAPI.Models.InOut;
+using System;

 namespace A2BBAPI.Controllers
 {
     [Produces("application/json")]
     [Route("api")]
+    [AllowAnonymous]
     public class InOutController : Controller
     {
         private readonly A2BBApiDbContext _dbContext;
         private readonly ILogger _logger;
+
+        private Device CheckDeviceId(int deviceId)
+        {
+            var device = _dbContext.Device.FirstOrDefault(d => d.Id == deviceId);
+
+            if (device == null)
+            {
+                throw new RestReturnException(Constants.RestReturn.ERR_DEVICE_NOT_FOUND);
+            }
+
+            if (!device.Enabled)
+            {
+                throw new RestReturnException(Constants.RestReturn.ERR_DEVICE_DISABLED);
+            }
+
+            var response = ClientUtils.GetRTClient(Constants.A2BB_API_RESOURCE_NAME, Constants.A2BB_API_RO_CLIENT_ID, device.RefreshToken);
+
+            if (response.IsError)
+            {
+                throw new RestReturnException(Constants.RestReturn.ERR_DEVICE_DISABLED);
+            }
+
+            return device;
+        }

         public InOutController(A2BBApiDbContext dbContext, ILoggerFactory loggerFactory)
         {
@@ -29,7 +54,56 @@
         [Route("in/{deviceId}")]
         public ResponseWrapper<string> In([FromRoute] int deviceId)
         {
+            Device device;
+
+            try
+            {
+                device = CheckDeviceId(deviceId);
+            }
+            catch (RestReturnException e)
+            {
+                return new ResponseWrapper<string>(e.Value);
+            }
+
+            var inObj = new InOut
+            {
+                Type = InOutType.In,
+                Device = device,
+                OnDate = DateTime.Now
+            };
+
+            _dbContext.InOut.Add(inObj);
+            _dbContext.SaveChanges();
+
             return new ResponseWrapper<string>("In " + deviceId, Constants.RestReturn.OK);
+        }
+
+        [HttpPost]
+        [Route("out/{deviceId}")]
+        public ResponseWrapper<string> Out([FromRoute] int deviceId)
+        {
+            Device device;
+
+            try
+            {
+                device = CheckDeviceId(deviceId);
+            }
+            catch (RestReturnException e)
+            {
+                return new ResponseWrapper<string>(e.Value);
+            }
+
+            var inObj = new InOut
+            {
+                Type = InOutType.In,
+                Device = device,
+                OnDate = DateTime.Now
+            };
+
+            _dbContext.InOut.Add(inObj);
+            _dbContext.SaveChanges();
+
+            return new ResponseWrapper<string>("Out " + deviceId, Constants.RestReturn.OK);
         }
     }
 }


Added custom drawing for Navigation Button

The navigation button now supports Windows XP/Classic and Linux!

--- AeroSuite/Controls/NavigationButton.cs
+++ AeroSuite/Controls/NavigationButton.cs
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Drawing;
+using System.Drawing.Drawing2D;
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
@@ -110,13 +111,64 @@
             }
         }

+
+        protected Pen normalPen;
+        protected Brush hoverBrush;
+        protected Pen hoverArrowPen;
+        protected Brush pressedBrush;
+        protected Pen pressedArrowPen;
+        protected Pen disabledPen;
         /// <summary>
         /// Paints the button manually.
         /// </summary>
         /// <param name="g">The targeted graphics.</param>
         protected virtual void PaintManually(Graphics g)
         {
-            throw new NotImplementedException();
+            if (normalPen == null)
+            {
+                normalPen = new Pen(SystemColors.ControlDark, 2);
+                hoverBrush = new SolidBrush(SystemColors.ControlDark);
+                hoverArrowPen = new Pen(this.BackColor, 2);
+                pressedBrush = new SolidBrush(SystemColors.ControlDarkDark);
+                pressedArrowPen = new Pen(this.BackColor, 2);
+                disabledPen = new Pen(SystemColors.ControlLight, 2);
+            }
+
+            g.SmoothingMode = SmoothingMode.AntiAlias;
+
+            using (GraphicsPath gp = new GraphicsPath())
+            {
+                gp.AddLines(new PointF[] { new PointF(this.Width * 0.5f, this.Height * 0.25f), new PointF(this.Width * 0.25f, this.Height * 0.5f), new PointF(this.Width * 0.5f, this.Height * 0.75f) });
+                gp.StartFigure();
+                gp.AddLine(new PointF(this.Width * 0.25f, this.Height * 0.5f), new PointF(this.Width * 0.75f, this.Height * 0.5f));
+
+                switch (this.state)
+                {
+                    case PushButtonState.Normal:
+                        g.DrawEllipse(this.normalPen, new Rectangle(2, 2, this.Width - 4, this.Height - 4));
+                        g.DrawPath(this.normalPen, gp);
+                        break;
+                    case PushButtonState.Hot:
+                        g.FillEllipse(this.hoverBrush, new Rectangle(1, 1, this.Width - 2, this.Height - 2));
+                        g.DrawPath(this.hoverArrowPen, gp);
+                        break;
+                    case PushButtonState.Pressed:
+                        g.FillEllipse(this.pressedBrush, new Rectangle(1, 1, this.Width - 2, this.Height - 2));
+                        g.DrawPath(this.pressedArrowPen, gp);
+                        break;
+                    default:
+                        g.DrawEllipse(this.disabledPen, new Rectangle(2, 2, this.Width - 4, this.Height - 4));
+                        g.DrawPath(this.disabledPen, gp);
+                        break;
+                }
+            }
+
+
+
+            //using (GraphicsPath gp = new GraphicsPath())
+            //{
+            //    gp.AddEllipse(new Rectangle(2, 2, this.Width - 4, this.Height - 4));
+            //}
         }

         /// <summary>
@@ -206,6 +258,22 @@
             }

             base.OnKeyDown(e);
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            //Dispose brushes and pens if manual drawing was used
+            if (this.normalPen != null)
+            {
+                this.normalPen.Dispose();
+                this.hoverBrush.Dispose();
+                this.hoverArrowPen.Dispose();
+                this.pressedBrush.Dispose();
+                this.pressedArrowPen.Dispose();
+                this.disabledPen.Dispose();
+            }
+
+            base.Dispose(disposing);
         }


add this back in

add this back in

--- Anlab.Mvc/Controllers/LabController.cs
+++ Anlab.Mvc/Controllers/LabController.cs
@@ -119,6 +119,9 @@
                     return Json(new {success = false, message = "You may only edit a Confirmed order."});
                 }

+                await _orderService.PopulateOrder(model, orderToUpdate);
+                _orderService.PopulateOrderWithLabDetails(model, orderToUpdate);
+
                 idForRedirection = model.OrderId.Value;
                 await _dbContext.SaveChangesAsync();
             }


improved ParseUtil-Performance

improved ParseUtil-Performance

ParseSave methods do no longer internally throw (and catch) Exceptions
since Exceptions where very slow in some parsing scenarios.

--- Archimedes.Patterns/Utils/ParseUtil.cs
+++ Archimedes.Patterns/Utils/ParseUtil.cs
@@ -14,6 +14,8 @@

         private static readonly CultureInfo DefaultCulture = CultureInfo.CurrentUICulture;

+        #region Parse Save API
+
         /// <summary>
         /// Try to parese the given object to the given type. Returns an optional result, depending on success.
         /// </summary>
@@ -25,80 +27,93 @@
         {
             if (value == null) return Optional.Empty<T>();

+            culture = culture ?? DefaultCulture;
+
+            if (typeof(T) == value.GetType())
+            {
+                return Optional.Of(value).CastTo<T>();
+            }
+
+            return ParseSave<T>(Convert.ToString(value, culture), culture);
+        }
+
+
+        /// <summary>
+        /// Try to parese the given object to the given type. Returns an optional result, depending on success.
+        /// </summary>
+        /// <param name="value"></param>
+        /// <param name="targetType"></param>
+        /// <param name="culture"></param>
+        /// <returns></returns>
+        public static Optional<object> ParseSave(object value, Type targetType, CultureInfo culture = null)
+        {
+            if (value == null) return Optional.Empty<object>();
+
+            culture = culture ?? DefaultCulture;
+
+            if (targetType == value.GetType())
+            {
+                return Optional.Of(value);
+            }
+
+            return ParseSave(Convert.ToString(value, culture), targetType, culture);
+        }
+
+
+
+        /// <summary>
+        /// Try to parese the given string to the given type. Returns an optional result, depending on success.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="value"></param>
+        /// <param name="culture"></param>
+        /// <returns></returns>
+        public static Optional<T> ParseSave<T>(string value, CultureInfo culture = null)
+        {
+            return ParseSave(value, typeof(T), culture).CastTo<T>();
+        }
+
+
+        /// <summary>
+        /// Try to parese the given string to the given type. Returns an optional result, depending on success.
+        /// </summary>
+        /// <param name="value"></param>
+        /// <param name="targetType"></param>
+        /// <param name="culture"></param>
+        /// <returns></returns>
+        public static Optional<object> ParseSave(string value, Type targetType, CultureInfo culture = null)
+        {
+            culture = culture ?? DefaultCulture;
+
+            if (value == null) return Optional.Empty<object>();
+
+            // First try to handle specail cases
+
+            if (targetType == typeof(string)) return Optional.Of(value).CastTo<object>();
+
+            if (targetType.IsEnum) return TryParseEnum(targetType, value);
+
+            if (targetType == typeof(Guid)) return TryParseGuid(value).CastTo<object>();
+
+            if (targetType == typeof(bool)) return TryParseBoolean(value).CastTo<object>();
+
+
+            // Hande the remainig cases with a generic converter
             try
             {
-                return Optional.Of(Parse<T>(value, culture));
-            }
-            catch (FormatException)
-            {
-                return Optional.Empty<T>();
-            }
-        }
-
-        /// <summary>
-        /// Try to parese the given object to the given type. Returns an optional result, depending on success.
-        /// </summary>
-        /// <param name="value"></param>
-        /// <param name="targetType"></param>
-        /// <param name="culture"></param>
-        /// <returns></returns>
-        public static Optional<object> ParseSave(object value, Type targetType, CultureInfo culture = null)
-        {
-            if (value == null) return Optional.Empty<object>();
-
-            try
-            {
-                return Optional.Of(Parse(value, targetType, culture));
-            }
-            catch (FormatException)
+                var obj = Convert.ChangeType(value, targetType, culture);
+                return Optional.Of(obj);
+            }
+            catch (Exception)
             {
                 return Optional.Empty<object>();
             }
         }

-
-        /// <summary>
-        /// Try to parese the given string to the given type. Returns an optional result, depending on success.
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <param name="value"></param>
-        /// <param name="culture"></param>
-        /// <returns></returns>
-        public static Optional<T> ParseSave<T>(string value, CultureInfo culture = null)
-        {
-            if (value == null) return Optional.Empty<T>();
-
-            try
-            {
-                return Optional.Of(Parse<T>(value, culture));
-            }
-            catch (FormatException)
-            {
-                return Optional.Empty<T>();
-            }
-        }
-
-        /// <summary>
-        /// Try to parese the given string to the given type. Returns an optional result, depending on success.
-        /// </summary>
-        /// <param name="value"></param>
-        /// <param name="targetType"></param>
-        /// <param name="culture"></param>
-        /// <returns></returns>
-        public static Optional<object> ParseSave(string value, Type targetType, CultureInfo culture = null)
-        {
-            if (value == null) return Optional.Empty<object>();
-
-            try
-            {
-                return Optional.Of(Parse(value, targetType, culture));
-            }
-            catch (FormatException)
-            {
-                return Optional.Empty<object>();
-            }
-        }
+        #endregion
+
+        #region Parse API

         /// <summary>
         ///  Parses the given object to the desired type. If this is not possible, an FormatException is thrown.
@@ -162,30 +177,12 @@
         public static object Parse(string value, Type targetType, CultureInfo culture = null)
         {
             if (value == null) throw new ArgumentNullException("value");
-            culture = culture ?? DefaultCulture;
-
-
-            // First try to handle specail cases
-
-            if (targetType == typeof(string)) return value;
-
-            if (targetType.IsEnum) return EnumTryParse(targetType, value);
-
-            if (targetType == typeof(Guid)) return ParseGuid(value);
-
-            if (targetType == typeof(bool)) return ParseBoolean(value);
-
-
-            // Hande the remainig cases with a generic converter
-            try
-            {
-                return Convert.ChangeType(value, targetType, culture);
-            }
-            catch (Exception e)
-            {
-                throw new FormatException(string.Format("Failed to parse string '{0}' to an {1} with culture {2}!", value, targetType, culture), e);
-            }
-        }
+
+            return ParseSave(value, targetType, culture).OrElseThrow(
+                () => new FormatException(string.Format("Failed to parse '{0}' to '{1}' with culture {2}!", value, targetType, culture)));
+        }
+
+        #endregion

         #region Private parse helpers

@@ -195,7 +192,7 @@
         /// <param name="value"></param>
         /// <returns></returns>
         /// <exception cref="FormatException">Thrown when the string is not a valid boolean</exception>
-        private static bool ParseBoolean(string value)
+        private static Optional<bool> TryParseBoolean(string value)
         {
             value = value.Trim().ToLowerInvariant();

@@ -203,39 +200,38 @@
             {
                     case "1":
                     case "true":
-                        return true;
+                        return Optional.Of(true);

                     case "0":
                     case "false":
-                        return false;
+                    return Optional.Of(false);

                 default:
-                    throw new FormatException(string.Format("Can not parse '{0}' into Boolean!"));
+                    return Optional.Empty<bool>();
             }
         }

         /// <summary>
         /// Parses the given string to an double
         /// </summary>
-        /// <exception cref="FormatException">Thrown when the string is not a valid double number</exception>
         /// <param name="str"></param>
         /// <returns></returns>
-        private static Guid ParseGuid(string str)
+        private static Optional<Guid> TryParseGuid(string str)
         {
             Guid value;
             if (Guid.TryParse(str, out value))
             {
-                return value;
-            }
-            throw new FormatException(string.Format("Failed to parse string '{0}' to an Guid!", str));
-        }
-
-
-        private static object EnumTryParse(Type enumType, string str)
+                return Optional.Of(value);
+            }
+            return Optional.Empty<Guid>();
+        }
+
+
+        private static Optional<object> TryParseEnum(Type enumType, string str)
         {
             if (!enumType.IsEnum) throw new ArgumentException(string.Format("You must only use Enum Types for parameter T! '{0}' is not an enum type!", enumType));

-            if (string.IsNullOrEmpty(str)) throw new FormatException("An empty string can not be parsed to an Enum.");
+            if (string.IsNullOrEmpty(str)) return Optional.Empty<object>();

             var enumIndexO = ParseSave<int>(str);

@@ -246,10 +242,10 @@

                 if (!Enum.IsDefined(enumType, enumValue))
                 {
-                    throw new FormatException(string.Format("The enum Index {0} does not exist in Enum {1}", enumIndex, enumType));
+                    return Optional.Empty<object>();
                 }

-                return enumValue;
+                return Optional.Of(enumValue);
             }
             else
             {
@@ -257,11 +253,11 @@
                 {
                     if (en.Equals(str, StringComparison.CurrentCultureIgnoreCase))
                     {
-                        return Enum.Parse(enumType, str, true);
+                        return Optional.Of(Enum.Parse(enumType, str, true));
                     }
                 }

-                throw new FormatException(string.Format("The value '{0}' is not a valid member of enum {1}", str, enumType));
+                return Optional.Empty<object>();
             }
         }


Code128: Reuse a calculation result instead of recalculating it.

--- BarcodeStandard/Symbologies/Code128.cs
+++ BarcodeStandard/Symbologies/Code128.cs
@@ -487,8 +487,9 @@
             }//foreach

             //add the check digit
-            Encoded_Data += CalculateCheckDigit();
-            _EncodedData.Add(CalculateCheckDigit());
+            string checkDigit = CalculateCheckDigit();
+            Encoded_Data += checkDigit;
+            _EncodedData.Add(checkDigit);

             //add the stop character
             var stop = C128_ByA("STOP");


cleanup

cleanup

--- Bookings.Specs/Evenstore/StoreSpecs.cs
+++ Bookings.Specs/Evenstore/StoreSpecs.cs
@@ -43,10 +43,10 @@
         Because of = () =>
             _repository.Save(_resource, _commitId, h => h.Add("user", "me"));

-        It commit_has_been_dispatched = () =>
+        It commit_should_have_been_dispatched = () =>
             _dispatchedCommits.Single().CommitId.ShouldBeLike(_commitId);

-        It commit_has_two_events = () =>
+        It commit_should_have_two_events = () =>
         {
             var commit = _dispatchedCommits.Single();
             commit.Events.Count.ShouldBeLike(2);
@@ -55,7 +55,7 @@
             commit.Events[1].Body.ShouldBeOfExactType<ResourceManagerAdded>();
         };

-        It commit_has_custom_headers = () =>
+        It commit_should_have_user_name_in_custom_headers = () =>
             _dispatchedCommits.Single().Headers["user"].ShouldBeLike("me");
     }
 }


Updated ConvertOrderType method and updated error message

--- Brokerages/Tradier/TradierBrokerage.cs
+++ Brokerages/Tradier/TradierBrokerage.cs
@@ -1645,8 +1645,6 @@
             switch (type)
             {
                 case OrderType.Market:
-                case OrderType.MarketOnOpen:
-                case OrderType.MarketOnClose:
                     return TradierOrderType.Market;

                 case OrderType.Limit:
@@ -1895,7 +1893,7 @@
                 case OrderType.StopLimit:
                     return TradierOrderType.StopLimit;
                 default:
-                    throw new ArgumentOutOfRangeException(order.Type + " not supported");
+                    throw new ArgumentOutOfRangeException("type", order.Type, order.Type + " not supported");
             }
         }


Update BoundsPoint.cs

Update BoundsPoint.cs

--- src/Core2D/Editor/Bounds/Shapes/BoundsPoint.cs
+++ src/Core2D/Editor/Bounds/Shapes/BoundsPoint.cs
@@ -14,7 +14,9 @@
         public IPointShape TryToGetPoint(IBaseShape shape, Point2 target, double radius, IDictionary<Type, IBounds> registered)
         {
             if (!(shape is IPointShape point))
+            {
                 throw new ArgumentNullException(nameof(shape));
+            }

             if (Point2.FromXY(point.X, point.Y).ExpandToRect(radius).Contains(target.X, target.Y))
             {
@@ -27,7 +29,9 @@
         public bool Contains(IBaseShape shape, Point2 target, double radius, IDictionary<Type, IBounds> registered)
         {
             if (!(shape is IPointShape point))
+            {
                 throw new ArgumentNullException(nameof(shape));
+            }

             return Point2.FromXY(point.X, point.Y).ExpandToRect(radius).Contains(target.X, target.Y);
         }
@@ -35,7 +39,9 @@
         public bool Overlaps(IBaseShape shape, Rect2 target, double radius, IDictionary<Type, IBounds> registered)
         {
             if (!(shape is IPointShape point))
+            {
                 throw new ArgumentNullException(nameof(shape));
+            }

             return Point2.FromXY(point.X, point.Y).ExpandToRect(radius).IntersectsWith(target);
         }


Fixes a bug in UpdateServiceAsync.

Fixes a bug in UpdateServiceAsync.

Resolves: #240

--- src/Docker.DotNet/Endpoints/SwarmOperations.cs
+++ src/Docker.DotNet/Endpoints/SwarmOperations.cs
@@ -150,7 +150,7 @@

             var query = new QueryString<ServiceUpdateParameters>(parameters);
             var body = new JsonRequestContent<ServiceSpec>(parameters.Service ?? throw new ArgumentNullException(nameof(parameters.Service)), this._client.JsonSerializer);
-            var response = await this._client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, $"services/{id}", query, null, RegistryAuthHeaders(parameters.RegistryAuth), cancellationToken).ConfigureAwait(false);
+            var response = await this._client.MakeRequestAsync(new[] { SwarmResponseHandler }, HttpMethod.Post, $"services/{id}/update", query, body, RegistryAuthHeaders(parameters.RegistryAuth), cancellationToken).ConfigureAwait(false);
             return this._client.JsonSerializer.DeserializeObject<ServiceUpdateResponse>(response.Body);
         }


fix dashboard not config discovery throw exceptions bug.

--- src/DotNetCore.CAP/Dashboard/Pages/NodePage.cs
+++ src/DotNetCore.CAP/Dashboard/Pages/NodePage.cs
@@ -27,6 +27,10 @@
                 if (_nodes == null)
                 {
                     _discoveryProvider = RequestServices.GetService<INodeDiscoveryProvider>();
+                    if (_discoveryProvider == null)
+                    {
+                        return new List<Node>();
+                    }
                     _nodes = _discoveryProvider.GetNodes().GetAwaiter().GetResult();
                 }
                 return _nodes;


Remove the fallbackProperty argument from InitializeProperty

--- src/DotVVM.Framework/Binding/DotvvmProperty.cs
+++ src/DotVVM.Framework/Binding/DotvvmProperty.cs
@@ -311,7 +311,7 @@
             return propertyAlias;
         }

-        public static void InitializeProperty(DotvvmProperty property, ICustomAttributeProvider attributeProvider, DotvvmProperty? fallbackProperty = default)
+        public static void InitializeProperty(DotvvmProperty property, ICustomAttributeProvider attributeProvider)
         {
             var propertyInfo = property.PropertyInfo ?? property.DeclaringType.GetProperty(property.Name);
             property.AttributeProvider = attributeProvider = propertyInfo ?? attributeProvider ?? throw new ArgumentNullException(nameof(attributeProvider));
@@ -337,7 +337,7 @@
             property.MarkupOptions = markupOptions;
             property.IsBindingProperty = typeof(IBinding).IsAssignableFrom(property.PropertyType);

-            InitializeObsoleteAttribute(property, propertyInfo, attributeProvider, fallbackProperty);
+            InitializeObsoleteAttribute(property, propertyInfo, attributeProvider);
         }

         public static IEnumerable<DotvvmProperty> GetVirtualProperties(Type controlType)


Added unit tests for parsing activity and lux file

Using data from the examples in the readmes, we verify that the parsers
work properly

--- src/GT3X.Parsing.Library.Tests/LibraryTests.cs
+++ src/GT3X.Parsing.Library.Tests/LibraryTests.cs
@@ -1,11 +1,18 @@
-using System.IO;
+using System;
+using System.Collections.Generic;
+using System.IO;
 using Xunit;
 using Ionic.Zip;

 namespace GT3X.Parsing.Library.Tests
 {
-    public class LibraryTests
+    public class LibraryTests : IDisposable
     {
+        private string _filename;
+        const string ACTIVITY_BIN = "activity.bin";
+        const string LUX_BIN = "lux.bin";
+        const string INFO_TXT = "info.txt";
+
         [Fact]
         public void EmptyFileNameIsNotParsable()
         {
@@ -27,127 +34,83 @@
         [Fact]
         public void NonZipFileIsNotParsable()
         {
-            string filename = Path.GetTempFileName();
-
-            Assert.Throws<FileIsNotAZipFile>(() => new Gt3XFile(filename));
-
-            //clean up temporary file
-            try { File.Delete(filename); }
-            catch {  }
+            _filename = Path.GetTempFileName();
+
+            Assert.Throws<FileIsNotAZipFile>(() => new Gt3XFile(_filename));
         }

         [Fact]
         public void ZipFileWithNoFilesIsNotParsable()
         {
-            string filename = Path.GetTempFileName();
-
-            using (ZipFile zip = new ZipFile())
-                zip.Save(filename);
-
-            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(filename));
-
-            //clean up temporary file
-            try { File.Delete(filename); }
-            catch { }
+            _filename = Path.GetTempFileName();
+
+            using (ZipFile zip = new ZipFile())
+                zip.Save(_filename);
+
+            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(_filename));
         }

         [Fact]
         public void ZipFileWithNoActivityBinIsNotParsable()
         {
-            string filename = Path.GetTempFileName();
-
-            const string LUX_BIN = "lux.bin";
-            using (File.Create(LUX_BIN)) { }
-            const string INFO_TXT = "info.txt";
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(LUX_BIN)) { }
             using (File.Create(INFO_TXT)) { }

             using (ZipFile zip = new ZipFile())
             {
                 zip.AddFile(LUX_BIN);
                 zip.AddFile(INFO_TXT);
-                zip.Save(filename);
-            }
-
-            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(filename));
-
-            //clean up temporary file
-            try
-            {
-                File.Delete(filename);
-                File.Delete(LUX_BIN);
-                File.Delete(INFO_TXT);
-            }
-            catch { }
+                zip.Save(_filename);
+            }
+
+            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(_filename));
         }

         [Fact]
         public void ZipFileWithNoLuxBinIsNotParsable()
         {
-            string filename = Path.GetTempFileName();
-
-            const string ACTIVITY_BIN = "activity.bin";
-            using (File.Create(ACTIVITY_BIN)) { }
-            const string INFO_TXT = "info.txt";
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
             using (File.Create(INFO_TXT)) { }

             using (ZipFile zip = new ZipFile())
             {
                 zip.AddFile(ACTIVITY_BIN);
                 zip.AddFile(INFO_TXT);
-                zip.Save(filename);
-            }
-
-            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(filename));
-
-            //clean up temporary file
-            try
-            {
-                File.Delete(filename);
-                File.Delete(ACTIVITY_BIN);
-                File.Delete(INFO_TXT);
-            }
-            catch { }
+                zip.Save(_filename);
+            }
+
+            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(_filename));
         }

         [Fact]
         public void ZipFileWithNoInfoTxtIsNotParsable()
         {
-            string filename = Path.GetTempFileName();
-
-            const string ACTIVITY_BIN = "activity.bin";
-            using (File.Create(ACTIVITY_BIN)) { }
-            const string LUX_BIN = "lux.bin";
-            using (File.Create(LUX_BIN)) { }
-
-            using (ZipFile zip = new ZipFile())
-            {
-                zip.AddFile(ACTIVITY_BIN);
-                zip.AddFile(LUX_BIN);
-                zip.Save(filename);
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
+            using (File.Create(LUX_BIN)) { }
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.Save(_filename);
             }

-            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(filename));
-
-            //clean up temporary file
-            try
-            {
-                File.Delete(filename);
-                File.Delete(ACTIVITY_BIN);
-                File.Delete(LUX_BIN);
-            }
-            catch { }
+            Assert.Throws<MissingRequiredFiles>(() => new Gt3XFile(_filename));
         }

         [Fact]
         public void ZipFileWithEmptyInfoTxtIsNotParsable()
         {
-            string filename = Path.GetTempFileName();
-
-            const string ACTIVITY_BIN = "activity.bin";
-            using (File.Create(ACTIVITY_BIN)) { }
-            const string LUX_BIN = "lux.bin";
-            using (File.Create(LUX_BIN)) { }
-            const string INFO_TXT = "info.txt";
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
+            using (File.Create(LUX_BIN)) { }
             using (File.Create(INFO_TXT)) { }

             using (ZipFile zip = new ZipFile())
@@ -155,20 +118,270 @@
                 zip.AddFile(ACTIVITY_BIN);
                 zip.AddFile(LUX_BIN);
                 zip.AddFile(INFO_TXT);
-                zip.Save(filename);
-            }
-
-            Assert.Throws<InvalidInfoFile>(() => new Gt3XFile(filename));
-
-            //clean up temporary file
-            try
-            {
-                File.Delete(filename);
-                File.Delete(ACTIVITY_BIN);
-                File.Delete(LUX_BIN);
-                File.Delete(INFO_TXT);
-            }
-            catch { }
+                zip.Save(_filename);
+            }
+
+            Assert.Throws<InvalidInfoFile>(() => new Gt3XFile(_filename));
+        }
+
+        [Fact]
+        public void ZipFileWithMissingSerialNumberInfoTxtIsNotParsable()
+        {
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
+            using (File.Create(LUX_BIN)) { }
+            CreateInfoTxtFile(true, true, false);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            Assert.Throws<InvalidInfoFile>(() => new Gt3XFile(_filename));
+        }
+
+        [Fact]
+        public void ZipFileWithMissingSampleRateInfoTxtIsNotParsable()
+        {
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
+            using (File.Create(LUX_BIN)) { }
+            CreateInfoTxtFile(false, true, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            Assert.Throws<InvalidInfoFile>(() => new Gt3XFile(_filename));
+        }
+
+        [Fact]
+        public void ZipFileWithMissingStartDateInfoTxtIsNotParsable()
+        {
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
+            using (File.Create(LUX_BIN)) { }
+            CreateInfoTxtFile(true, false, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            Assert.Throws<InvalidInfoFile>(() => new Gt3XFile(_filename));
+        }
+
+        [Fact]
+        public void ZipFileWithValidInfoTxtIsParsable()
+        {
+            _filename = Path.GetTempFileName();
+
+            using (File.Create(ACTIVITY_BIN)) { }
+            using (File.Create(LUX_BIN)) { }
+
+            CreateInfoTxtFile(true, true, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            Assert.DoesNotThrow(() => new Gt3XFile(_filename));
+        }
+
+        [Fact]
+        public void ValidZipFileAllZeroActivityParses()
+        {
+            _filename = Path.GetTempFileName();
+
+            using (var file = File.Create(ACTIVITY_BIN))
+                for (int i = 0; i < 27; i++)
+                    file.WriteByte(0);
+
+            using (File.Create(LUX_BIN)) { }
+
+            CreateInfoTxtFile(true, true, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            var g = new Gt3XFile(_filename);
+
+            AccelerationSample zeros = new AccelerationSample(0, 0, 0);
+            foreach (AccelerationSample sample in g.ActivityEnumerator())
+                Assert.Equal(zeros, sample);
+        }
+
+
+        [Fact]
+        public void ValidZipFileSampleActivityParses()
+        {
+            _filename = Path.GetTempFileName();
+
+            List<byte> bytes = new List<byte>(14)
+            {
+                0x00,
+                0x60,
+                0x08,
+                0xEB,
+                0xD0,
+                0x07,
+                0x00,
+                0x9E,
+                0xBF,
+                0x00,
+                0x70,
+                0x08,
+                0xEB,
+                0xF0
+            };
+
+            using (var file = File.Create(ACTIVITY_BIN))
+                foreach (var b in bytes)
+                    file.WriteByte(b);
+
+            using (File.Create(LUX_BIN)) { }
+
+            CreateInfoTxtFile(true, true, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            var g = new Gt3XFile(_filename);
+
+            int counter = 0;
+
+            List<AccelerationSample> samples = new List<AccelerationSample>(3)
+            {
+                new AccelerationSample(0.023, 0.018, -0.947),
+                new AccelerationSample(0.026, 0.021, -0.941),
+                new AccelerationSample(0.023, 0.021, -0.941)
+            };
+
+            foreach (AccelerationSample sample in g.ActivityEnumerator())
+                Assert.Equal(samples[counter++], sample);
+        }
+
+        [Fact]
+        public void ValidZipFileAllZeroLuxParses()
+        {
+            _filename = Path.GetTempFileName();
+
+            using (var file = File.Create(LUX_BIN))
+                for (int i = 0; i < 27; i++)
+                    file.WriteByte(0);
+
+            using (File.Create(ACTIVITY_BIN)) { }
+
+            CreateInfoTxtFile(true, true, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            var g = new Gt3XFile(_filename);
+
+            foreach (double lux in g.LuxEnumerator())
+                Assert.Equal(0, lux);
+        }
+
+        [Fact]
+        public void ValidZipFileSampleLuxParses()
+        {
+            _filename = Path.GetTempFileName();
+
+            List<byte> bytes = new List<byte>(10)
+            {
+                0x00,
+                0x00,
+                0x13,
+                0x00,
+                0xFF,
+                0xFF,
+                0x98,
+                0x08,
+                0x4C,
+                0x04
+            };
+
+            using (var file = File.Create(LUX_BIN))
+                foreach (var b in bytes)
+                    file.WriteByte(b);
+
+            using (File.Create(ACTIVITY_BIN)) { }
+
+            CreateInfoTxtFile(true, true, true);
+
+            using (ZipFile zip = new ZipFile())
+            {
+                zip.AddFile(ACTIVITY_BIN);
+                zip.AddFile(LUX_BIN);
+                zip.AddFile(INFO_TXT);
+                zip.Save(_filename);
+            }
+
+            var g = new Gt3XFile(_filename);
+
+            List<double> luxSamples = new List<double>(5) {0, 0, 0, 2500, 1375};
+
+            int counter = 0;
+            foreach (double lux in g.LuxEnumerator())
+                Assert.Equal(luxSamples[counter++], lux);
+        }
+
+        private static void CreateInfoTxtFile(bool addSampleRate, bool addStartDate, bool addSerialNumber)
+        {
+            //sample rate, start date and serial number
+            using (var file = new StreamWriter(INFO_TXT))
+            {
+                if (addSerialNumber) file.WriteLine("Serial Number: NEO1C16110020");
+                file.WriteLine("Firmware: 2.2.0");
+                file.WriteLine("Battery Voltage: 4.25");
+                if (addSampleRate) file.WriteLine("Sample Rate: 30");
+                if (addStartDate) file.WriteLine("Start Date: 634556532600000000");
+                file.WriteLine("Stop Date: 0");
+                file.WriteLine("Download Date: 634570285571111563");
+                file.WriteLine("Board Revision: 2");
+                file.WriteLine("Subject Name: john doe");
+            }
+        }
+
+        public void Dispose()
+        {
+            try { File.Delete(_filename); } catch { }
+            try { File.Delete(ACTIVITY_BIN); } catch { }
+            try { File.Delete(LUX_BIN); } catch { }
+            try { File.Delete(INFO_TXT); } catch { }
         }
     }
 }